Copilot commented on code in PR #42120:
URL: https://github.com/apache/superset/pull/42120#discussion_r3605932605


##########
superset/utils/screenshots.py:
##########
@@ -326,15 +361,24 @@ def compute_and_cache(  # pylint: 
disable=too-many-arguments
                         image = None
 
                 # Cache the result (success or error) to avoid immediate 
retries
-                if image:
+                invalid_reason = validate_screenshot_image(image)
+                if image and invalid_reason is None:
                     with event_logger.log_context(
                         f"screenshot.cache.{self.thumbnail_type}"
                     ):
                         cache_payload.update(image)
-                elif cache_payload.status != StatusValues.ERROR:
-                    # Only call error() if not already set — avoids overwriting
-                    # the timestamp recorded when the actual failure occurred 
above.
-                    cache_payload.error()
+                else:
+                    if invalid_reason:
+                        logger.warning(
+                            "Not caching screenshot result for %s: %s image 
payload",
+                            cache_key,
+                            invalid_reason,
+                        )

Review Comment:
   The warning message "Not caching screenshot result …" is misleading because 
the code still writes a cache entry (with ERROR status) right after this. This 
can confuse operators reading logs during incident/debugging. Consider 
rephrasing to indicate you're caching an ERROR payload, and avoid duplicating 
this warning when the payload is already ERROR due to an exception earlier in 
the method.



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