codeant-ai-for-open-source[bot] commented on code in PR #42118:
URL: https://github.com/apache/superset/pull/42118#discussion_r3692396771
##########
superset/utils/screenshot_utils.py:
##########
@@ -377,12 +471,36 @@ def take_tiled_screenshot(
load_wait,
context_suffix,
)
+ readiness_wait_elapsed = time.monotonic() - tile_wait_start
# Wait for chart animations (e.g. ECharts) to finish after spinner
clears.
# The global animation wait before tiling only covers the first
tile;
- # subsequent tiles need their own wait after data loads.
+ # subsequent tiles need their own wait after data loads. Capped at
+ # whatever remains of the budget; unlike the readiness wait above
this
+ # is cosmetic settling, not a readiness check, so we simply skip it
+ # (rather than raise) once the budget runs out.
+ animation_wait_elapsed = 0.0
if animation_wait > 0:
- page.wait_for_timeout(animation_wait * 1000)
+ elapsed = time.monotonic() - start_time
+ remaining_budget = wait_budget_seconds - elapsed
+ tile_animation_wait = max(0, min(animation_wait,
remaining_budget))
+ if tile_animation_wait > 0:
+ animation_wait_start = time.monotonic()
+ page.wait_for_timeout(tile_animation_wait * 1000)
+ animation_wait_elapsed = time.monotonic() -
animation_wait_start
Review Comment:
**Suggestion:** After the capped animation wait completes, the code proceeds
directly to `page.screenshot()` without checking the remaining budget. If the
animation wait consumes the final available time, the tile is still captured
after the hard budget has expired, and if this is the last tile the function
returns successfully despite exceeding the task limit. Recheck the budget
before capture and raise `TiledScreenshotBudgetExceededError` when it is
exhausted. [incorrect control flow]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Tiled report capture can exceed its safe task budget.
- ⚠️ Celery cleanup time can be consumed by screenshot capture.
- ⚠️ Last tiles may succeed after budget exhaustion.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=452182239d354cd7b752b155df6d37aa&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=452182239d354cd7b752b155df6d37aa&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/screenshot_utils.py
**Line:** 482:490
**Comment:**
*Incorrect Control Flow: After the capped animation wait completes, the
code proceeds directly to `page.screenshot()` without checking the remaining
budget. If the animation wait consumes the final available time, the tile is
still captured after the hard budget has expired, and if this is the last tile
the function returns successfully despite exceeding the task limit. Recheck the
budget before capture and raise `TiledScreenshotBudgetExceededError` when it is
exhausted.
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%2F42118&comment_hash=425fcb1612db3969bc016b8e094f165af558b6154f2491d4fbc37f3bf13e6510&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42118&comment_hash=425fcb1612db3969bc016b8e094f165af558b6154f2491d4fbc37f3bf13e6510&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]