eschutho opened a new pull request, #46061:
URL: https://github.com/apache/superset/pull/46061

   ### SUMMARY
   
   The "delete tab" confirmation says it will deactivate any related alerts or 
reports, but deleting a dashboard tab or a native filter **through the 
dashboard UI** left the affected reports active. They kept sending, marked as 
successful: a deleted tab silently sent the first tab, a deleted filter 
silently sent unfiltered data, and a saved filter that no longer existed sent 
unfiltered or "No data" results. The same tab deletion through the API (sending 
`position_json`) did deactivate the report.
   
   **Root causes**
   1. **Tabs:** the dashboard UI save sends the layout inside 
`json_metadata.positions` and no `position_json`. 
`UpdateDashboardCommand.process_tab_diff` (`find_deleted_tabs`) only read 
`position_json`, so a UI save never saw a deleted tab. (`set_dash_metadata` 
writes `position_json` from `positions`, but after the diff has already run.)
   2. **Filters:** the filter modal saves through `PUT 
/api/v1/dashboard/<id>/filters`, handled by 
`UpdateDashboardNativeFiltersCommand`, which never ran the filter diff or the 
report deactivation. The existing `process_native_filter_diff` also can't be 
reused as is, because it reads `json_metadata`, which that payload doesn't 
carry.
   3. **Execution time:** `ReportSchedule.get_native_filters_params` never 
checked that a saved native filter id still exists on the dashboard.
   
   **Changes**
   - `find_deleted_tabs` reads `json_metadata.positions` first and falls back 
to `position_json`, with the same precedence as `run()` and `set_dash_metadata`.
   - `UpdateDashboardNativeFiltersCommand.run` records the stored filter ids, 
applies the update, and deactivates the reports that use ids which disappeared. 
Deleted filters are found by comparing stored vs. resulting ids rather than 
trusting the payload's `deleted` list: an id that is both `deleted` and 
`modified` survives, and a `reordered` list silently drops any filter it omits.
   - After the DAO's substring lookup, matching is confirmed exactly on the 
parsed report: the tab id must be in the report's anchor, or the 
`nativeFilterId` must equal the deleted id. Previously deleting `TAB-1` could 
match a report anchored to `TAB-10`, and an id appearing inside a filter 
*value* could match.
   - At execution time, a saved filter that no longer exists adds a warning to 
the execution log. The run is not failed. A missing dashboard or malformed 
metadata yields no warning and no error.
   
   Out of scope: modified (not deleted) filters, the confirmation dialog text, 
and the existing behaviour of `process_native_filter_diff` when 
`native_filter_configuration` is omitted from a payload.
   
   ### TESTING INSTRUCTIONS
   
   ```
   pytest tests/unit_tests/commands/dashboard/update_test.py \
          tests/unit_tests/reports/model_test.py
   ```
   
   - Tab: a UI-shaped update (`json_metadata.positions`, no `position_json`) 
that removes a tab used by a report deactivates it; `positions` takes 
precedence over `position_json`; `TAB-1` deleted leaves a report anchored to 
`TAB-10` active.
   - Filters: `PUT .../filters` with a deleted id deactivates the report; an id 
in both `deleted` and `modified` does not; a filter dropped by an incomplete 
`reordered` list does; an id that only appears inside a filter value does not 
match.
   - Execution: a stale `nativeFilterId` adds a warning; a missing dashboard or 
malformed metadata does not raise.
   
   Manual: create a report on a dashboard tab and a native filter, delete the 
tab (or the filter) in the dashboard UI and save, and confirm the report is 
deactivated and its editors are emailed.
   
   Test limitation: there is no database-backed HTTP-level test of the `PUT` 
routes; the unit tests drive the real native-filter DAO update and mock the 
report DAO and tab lookup.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags: `ALERT_REPORTS_FILTER`, `ALERT_REPORT_TABS`
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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

  • [PR] fix(dashboard): deactivat... eschutho (via GitHub) via notifications

Reply via email to