mikebridge opened a new pull request, #39973: URL: https://github.com/apache/superset/pull/39973
### SUMMARY 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 a downstream `dashboard.id` access in the `dashboard.uuid if dashboard and dashboard.uuid else dashboard.id` ternary. This is a pre-existing latent bug. `ReportSchedule.dashboard` and `.chart` are 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., `DeleteChartCommand` blocks 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. Tracked at [sc-106186](https://app.shortcut.com/preset/story/106186). ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF N/A — backend-only change; no UI or API surface changes. ### TESTING INSTRUCTIONS ```bash pytest tests/unit_tests/commands/report/execute_test.py -v ``` Expected: 48 passed (47 pre-existing + the new `test_get_url_raises_unexpected_error_when_target_is_missing`). The new test constructs a `ReportSchedule` mock with both `.chart` and `.dashboard` returning `None` and asserts `_get_url` raises `ReportScheduleUnexpectedError` with a message containing the report id, name, chart_id, and dashboard_id. ### ADDITIONAL INFORMATION - [X] Has associated issue: [sc-106186](https://app.shortcut.com/preset/story/106186) - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration - [ ] Introduces new feature or API - [ ] Removes existing feature or API -- 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]
