rebenitez1802 commented on code in PR #43523:
URL: https://github.com/apache/superset/pull/43523#discussion_r3873545278


##########
superset/utils/screenshots.py:
##########
@@ -117,14 +117,22 @@ def __init__(
 
     @classmethod
     def from_dict(cls, payload: ScreenshotCachePayloadType) -> 
ScreenshotCachePayload:
-        return cls(
+        instance = cls(
             image=base64.b64decode(payload["image"]) if payload["image"] else 
None,
             status=StatusValues(payload["status"]),
             timestamp=payload["timestamp"],
             # `.get` rather than `payload["scope"]`: entries cached before this
             # field existed won't have the key.
             scope=payload.get("scope"),
         )
+        # `__init__` infers UPDATED whenever an image is present -- convenient 
for
+        # the `ScreenshotCachePayload(image=bytes)` and legacy 
bytes-reconstruction
+        # paths, but wrong when rehydrating a persisted entry: an ERROR or 
COMPUTING
+        # entry keeps its previous image, and re-inferring UPDATED here would 
mask it
+        # as fresh and bypass the shorter ERROR/COMPUTING recovery TTLs. 
Restore the
+        # persisted status explicitly.
+        instance.status = StatusValues(payload["status"])

Review Comment:
   Good catch — fixed. Pulled the timestamp math into a shared guarded 
`_age_seconds()` so `is_error_cache_ttl_expired`/`is_computing_stale` (and 
`is_updated_stale`) all treat an unusable/tz-aware timestamp as expired → 
recompute instead of raising. Added tz-aware + unparseable tests for both.



-- 
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