bito-code-review[bot] commented on code in PR #43523:
URL: https://github.com/apache/superset/pull/43523#discussion_r4027725153


##########
superset/charts/api.py:
##########
@@ -1208,9 +1207,20 @@ def build_response(status_code: int) -> WerkzeugResponse:
                 task_status=cache_payload.get_status(),
             )
 
-        if cache_payload.should_trigger_task(force, 
expected_scope=f"chart:{chart.id}"):
+        if cache_payload.should_trigger_task(
+            force,
+            expected_scope=f"chart:{chart.id}",
+            check_updated_staleness=screenshot_obj.supports_updated_staleness,
+        ):
             logger.info("Triggering screenshot ASYNC")
-            screenshot_obj.cache.set(cache_key, 
ScreenshotCachePayload().to_dict())
+            # Mark the entry in-flight without discarding any retained image: a
+            # fresh empty payload here would 404 the image_url during the retry
+            # and, if the render fails again, permanently lose the last-good
+            # image. `computing()` keeps `_image`, refreshes the timestamp and
+            # flips status to COMPUTING, so the read path keeps serving the
+            # last-good image while the task runs.
+            cache_payload.computing()

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>First render never computed</b></div>
   <div id="fix">
   
   On a first render there is no cached image, so `cache_payload` is a fresh 
PENDING payload. Calling `computing()` unconditionally flips it to COMPUTING 
with a fresh timestamp; the worker's `compute_and_cache()` then reads it back 
and `should_trigger_task(force=None, ...)` returns False (COMPUTING not stale), 
so it logs "Skipping compute" and never renders. Branch on image presence: 
`computing()` only when `_image` is set, else `pending()`.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #8f8675</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to