Repository navigation
fix(reports): null-guard execution against missing target - #39973
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #39973 +/- ##
==========================================
- Coverage 65.03% 65.03% -0.01%
==========================================
Files 2744 2744
Lines 153627 153630 +3
Branches 35226 35227 +1
==========================================
+ Hits 99910 99911 +1
- Misses 51810 51813 +3
+ Partials 1907 1906 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Note on the Codecov 66.67% patch coverage warning Both Codecov gates (
The codepath the new guard protects (both Project coverage actually rose by +0.06% with this change. |
|
Note: This same job ran twice on the same SHA (
Same code, opposite outcomes — canonical flake signature. The failing tests are also in completely unrelated files ( The non-prefix variant I don't have rerun rights on this repo (fork PR). If a committer reviewing this could kick off a rerun, the flake should clear and the PR will be fully green. |
Code Review Agent Run #418495Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
74040fc to
2859da4
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a defensive null-guard in BaseReportState._get_url to raise a meaningful ReportScheduleUnexpectedError when both chart and dashboard relationships are None, instead of crashing with an AttributeError on dashboard.id. Also simplifies the dashboard id/slug selection.
Changes:
- Raise
ReportScheduleUnexpectedErrorearly in_get_urlwhen neither chart nor dashboard is resolvable. - Simplify
dashboard_id_or_slugselection todashboard.uuid or dashboard.id. - Add a unit test covering the new guard.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| superset/commands/report/execute.py | Adds null-guard at top of _get_url and simplifies dashboard id/slug fallback. |
| tests/unit_tests/commands/report/execute_test.py | Adds test asserting the guard raises with a message containing report id, name, chart_id, dashboard_id. |
2859da4 to
91dada3
Compare
Code Review Agent Run #bbce59Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
91dada3 to
964a591
Compare
Code Review Agent Run #97d1f0Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
964a591 to
0dcc66d
Compare
Code Review Agent Run #528a35Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
0dcc66d to
1c3f86f
Compare
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Code Review Agent Run #b6c46fActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
rusackas
left a comment
There was a problem hiding this comment.
Bot comments worth a look, but seems like a good defensive fix. Test covers it well, LGTM
1c3f86f to
e534a5c
Compare
45b338c to
ac224bd
Compare
|
@rusackas The rebased PR is approved, mergeable, and all addressed review threads are resolved. The fresh required Playwright run hit one unrelated timeout in EDIT: I will just rebase and push to trigger CI again |
ac224bd to
41a858c
Compare
41a858c to
7365845
Compare
Adds a defensive null-guard at the top of ``BaseReportState._get_url`` (``superset/commands/report/execute.py``). When both ``self._report_schedule.chart`` and ``self._report_schedule.dashboard`` are ``None``, the method now raises ``ReportScheduleUnexpectedError`` with a message identifying the report and the missing target, rather than crashing on the downstream ``dashboard.id`` access at the (formerly) ``else`` branch of the ``dashboard.uuid if dashboard and dashboard.uuid else dashboard.id`` ternary. This is a pre-existing latent bug — ``_report_schedule.dashboard`` was already nullable in principle, but reaching the ``None`` state was practically unreachable in master because every code path that orphaned a report was blocked by ``DeleteChartCommand`` / ``DeleteDashboardCommand`` validation. The soft-delete branch makes the bug newly reachable through admin tooling / direct SQLAlchemy paths that bypass the validation: the visibility filter applied to relationship loads returns ``None`` for soft-deleted targets even though the FK still references the row. The existing API protections still block the most common trigger path (``DELETE /api/v1/chart/<id>`` returns 422 when reports reference the chart), so production scheduled reports are unaffected. Adds a unit test in ``tests/unit_tests/commands/report/execute_test.py`` that constructs a ``ReportSchedule`` mock with both relationships returning ``None`` and asserts the new error is raised with the right identifying details (report id, name, chart_id, dashboard_id). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
7365845 to
643491e
Compare
Code Review Agent Run #fac7abActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
| dashboard_id_or_slug = ( | ||
| dashboard.uuid if dashboard and dashboard.uuid else dashboard.id | ||
| dashboard.uuid if dashboard.uuid is not None else dashboard.id | ||
| ) |
There was a problem hiding this comment.
Suggestion: Provide an explicit type annotation for this newly added computed variable so its expected identifier type is statically enforced. [custom_rule]
Severity Level: Minor 🧹
Why it matters? ⭐
This newly added computed local variable is inferable as a value that can be annotated, but no type hint is provided. That matches the custom Python type-hint rule, so the violation is real.
Rule source 📖
.cursor/rules/dev-standard.mdc (line 28)
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset/commands/report/execute.py
**Line:** 327:329
**Comment:**
*Custom Rule: Provide an explicit type annotation for this newly added computed variable so its expected identifier type is statically enforced.
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| get_url_path = mocker.patch( | ||
| "superset.commands.report.execute.get_url_path", | ||
| return_value="/chart", | ||
| ) |
There was a problem hiding this comment.
Suggestion: Add an explicit type annotation for this newly introduced local variable to satisfy the type-hint requirement for annotatable variables. [custom_rule]
Severity Level: Minor 🧹
Why it matters? ⭐
This is newly added Python code in a test, and the local variable get_url_path is inferable and can be annotated (for example as a mock object). Since the custom rule requires type hints on annotatable new or modified variables, this omission is a real violation.
Rule source 📖
.cursor/rules/dev-standard.mdc (line 28)
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** tests/unit_tests/commands/report/execute_test.py
**Line:** 2357:2360
**Comment:**
*Custom Rule: Add an explicit type annotation for this newly introduced local variable to satisfy the type-hint requirement for annotatable variables.
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 fixCo-authored-by: Mike Bridge <[email protected]> Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]> Co-authored-by: Evan Rusackas <[email protected]>
SUMMARY
Adds a defensive null-guard at the top of
BaseReportState._get_url(superset/commands/report/execute.py). When bothself._report_schedule.chartandself._report_schedule.dashboardareNone, the method now raisesReportScheduleUnexpectedErrorwith a message identifying the report and the missing target, rather than crashing on a downstreamdashboard.idaccess in thedashboard.uuid if dashboard and dashboard.uuid else dashboard.idternary. Previous behaviour was to raise aAttributeError: 'NoneType' object has no attribute 'id'and surface it in the UI.This is a pre-existing latent issue.
ReportSchedule.dashboardand.chartare nullable in the schema, but reaching the dual-None state was practically unreachable in master because every code path that could orphan a report blocks the deletion (e.g.,DeleteChartCommandblocks delete when reports reference the chart). The guard makes the failure mode explicit and informative if any future code path (or any direct DB write) ever does land in that state.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — backend-only change; no UI or API surface changes.
TESTING INSTRUCTIONS
Expected: 48 passed (47 pre-existing + the new
test_get_url_raises_unexpected_error_when_target_is_missing).The new test constructs a
ReportSchedulemock with both.chartand.dashboardreturningNoneand asserts_get_urlraisesReportScheduleUnexpectedErrorwith a message containing the report id, name, chart_id, and dashboard_id.ADDITIONAL INFORMATION