codeant-ai-for-open-source[bot] commented on code in PR #41080:
URL: https://github.com/apache/superset/pull/41080#discussion_r3417344079


##########
superset/utils/webdriver.py:
##########
@@ -375,15 +375,12 @@ def get_screenshot(  # pylint: disable=too-many-locals, 
too-many-statements  # n
                             animation_wait=selenium_animation_wait,
                         )
                         if img is None:
-                            logger.warning(
-                                (
-                                    "Tiled screenshot failed, "
-                                    "falling back to standard screenshot"
-                                )
-                            )
-                            img = WebDriverPlaywright._get_screenshot(
-                                page, element, element_name
+                            logger.error(
+                                "Tiled screenshot failed at url %s; "
+                                "not falling back to avoid sending a blank 
PDF",
+                                url,
                             )
+                            return None

Review Comment:
   **Suggestion:** Returning `None` on tiled capture failure causes 
partial-success behavior for multi-tab dashboards: `_get_screenshots()` only 
raises when *all* captures are missing, so one failed tab can be silently 
dropped while the report is still sent. Raise an exception here (instead of 
returning `None`) so any failed tab correctly fails the report run. [logic 
error]
   
   <details>
   <summary><b>Severity Level:</b> Critical 🚨</summary>
   
   ```mdx
   - ❌ Multi-tab dashboard reports omit failed tabs silently.
   - ❌ Report PDFs sent to users can be incomplete.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Trigger a scheduled dashboard report that uses multiple tab URLs via
   `AsyncExecuteReportScheduleCommand.run` in 
`superset/commands/report/execute.py:28-58`,
   which drives report execution and eventually calls the private 
`_get_screenshots()` helper
   at `superset/commands/report/execute.py:419`.
   
   2. In `_get_screenshots` (around 
`superset/commands/report/execute.py:419-487`), for a
   dashboard schedule it builds a list of `DashboardScreenshot` instances from 
multiple URLs:
   `urls = self.get_dashboard_urls()` and `screenshots = 
[DashboardScreenshot(url, ...,
   window_size=..., thumb_size=... ) for url in urls]` (lines 42–55 in the tool 
output), so
   each tab/anchor becomes a separate screenshot object.
   
   3. For each `DashboardScreenshot`, `_get_screenshots` calls
   `screenshot.get_screenshot(user=user)` inside the loop (line ~60 / actual 
~469) and only
   appends results when truthy: `if imge := 
screenshot.get_screenshot(user=user):
   imges.append(imge)`; after the loop it raises 
`ReportScheduleScreenshotFailedError` only
   if `imges` is empty: `if not imges: raise 
ReportScheduleScreenshotFailedError()` at
   `superset/commands/report/execute.py:495-496`.
   
   4. When the Playwright path is enabled (`PLAYWRIGHT_REPORTS_AND_THUMBNAILS` 
flag) and a
   given dashboard URL meets the tiling criteria (large chart count/height),
   `BaseScreenshot.get_screenshot` in `superset/utils/screenshots.py:211-221` 
selects
   `WebDriverPlaywright` (driver()) and calls its `get_screenshot`, which, on 
tiled failure,
   executes the `if img is None: logger.error(...); return None` block at
   `superset/utils/webdriver.py:238-244`. For that one tab, 
`screenshot.get_screenshot`
   returns `None`, so `_get_screenshots` simply skips appending it but still 
succeeds if
   other tabs returned bytes, producing a PDF missing that tab instead of 
failing the whole
   report, confirming the partial-success behavior described in the suggestion.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=b9e3cec67aeb43878acf8d0f44f1cc25&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=b9e3cec67aeb43878acf8d0f44f1cc25&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/utils/webdriver.py
   **Line:** 378:383
   **Comment:**
        *Logic Error: Returning `None` on tiled capture failure causes 
partial-success behavior for multi-tab dashboards: `_get_screenshots()` only 
raises when *all* captures are missing, so one failed tab can be silently 
dropped while the report is still sent. Raise an exception here (instead of 
returning `None`) so any failed tab correctly fails the report run.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41080&comment_hash=be8a9784567b6b11abc1c71bde901838416b4cd5499b9b780729449186e0058c&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41080&comment_hash=be8a9784567b6b11abc1c71bde901838416b4cd5499b9b780729449186e0058c&reaction=dislike'>👎</a>



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