Repository navigation
fix(dashboard): save an unreadable layout chart as a missing-chart tile - #45800
rebenitez1802 merged 15 commits into
Conversation
A dashboard save, create or copy rebuilds chart membership from the layout it is sent. Only link a chart the layout adds if the caller can read it; charts already on the dashboard (archived ones included) and, for a copy, the source dashboard's charts stay accepted, so existing saves keep working. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The update command refuses a layout chart the caller cannot read in validate(), before tab and native-filter removals deactivate reports and email their owners. The editors and viewers of the charts being checked are loaded in two queries instead of per chart. Tests cover a chart the caller reads through a granted dataset but does not edit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… charts in the layout check Co-Authored-By: Claude Opus 5.5 <[email protected]>
…art-ids Co-Authored-By: Claude Opus 5.5 <[email protected]>
…art-ids Keep both sides in set_dash_metadata: install the stored membership baseline, refuse unreadable new layout charts against the stored dashboard_slices rows, then keep archived members the layout omits. Kept archived charts are limited to stored members. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Being archived does not exempt a chart from the layout access check: an archived chart that is not already a member and that the caller cannot read is refused, and the stored membership is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Saving a dashboard layout that adds a chart the user cannot read is refused on update, create and copy. Existing members, archived ones included, and a copy's source charts are not checked.
A dashboard save, create or copy whose layout adds a chart the caller cannot read no longer fails with 422. The chart is left unlinked and its tile is saved as the same placeholder a nonexistent chart gets, so the response does not reveal that the chart exists. Existing members, archived ones included, and a copy's source charts are not checked. Copying with charts handles a tile for a chart outside the source the same way when the caller cannot read it; a readable one still refuses the copy.
A PUT that sends only position_json kept a tile for an existing chart the caller cannot read, while a nonexistent chart's tile became the missing-chart placeholder, so reading the layout back revealed which charts exist. The raw path and the copy-with-charts layout now repair a non-member chart the caller cannot read like a missing one. The copy-with-charts handling moves into that shared repair, which also covers every save route with a parity test.
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #45800 +/- ##
==========================================
- Coverage 85.00% 85.00% -0.01%
==========================================
Files 3080 3080
Lines 209252 209251 -1
Branches 49292 49292
==========================================
- Hits 177881 177878 -3
- Misses 27990 27991 +1
- Partials 3381 3382 +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:
|
…readable-placeholder
| unreadable_ids: set[int] = _unreadable_new_chart_ids( | ||
| current_slices, member_ids | (allowed_chart_ids or set()) | ||
| ) | ||
| current_slices = [ | ||
| chart for chart in current_slices if chart.id not in unreadable_ids | ||
| ] |
There was a problem hiding this comment.
Suggestion: If chart access is revoked after this check but before the membership update commits, the stale result still links it, allowing dashboard membership to grant access.
Assessment: 🔴 Critical · 🔁 Occurrence: Rarely · 🏷️ Race condition
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset/daos/dashboard.py
**Line:** 887:892
**Comment:**
*Race Condition: If chart access is revoked after this check but before the membership update commits, the stale result still links it, allowing dashboard membership to grant access.
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
gabotorresruiz
left a comment
There was a problem hiding this comment.
Thanks @mikebridge, LGTM!
I ran the unit and integration selections from the description locally on sqlite (all green here, and the new tests fail against master as expected), and compared every save route with a nonexistent chart against an unreadable one: same status, response, stored layout, metadata and membership. CI is green.
…le (#45800) Co-authored-by: Claude Opus 5.5 <[email protected]>
…chart's own requests (reduced backport of #44215) The security manager change applies as is. On 7.0 the copy and native-filter checks build on the reduced #45538 layout check rather than master's #44028 and #45800 helpers: a copy checks the source charts it carries (all of them when duplicating or without a layout, else those its layout places) and its native-filter targets, and the update command checks new filter targets before its side effects. The dashboard datasets endpoint passes the grant to the serializer, since 7.0's DAO takes no access callback. Tests for files absent on 7.0 are left out, and 7.0's copy test now expects the refusal. (cherry picked from commit 2645396, reduced)
SUMMARY
Saving a dashboard layout that contains a tile for a chart you can't read no longer fails. The chart isn't attached to the dashboard, and its tile is saved as the same "This chart no longer exists." placeholder a deleted chart gets. This typically happens with a stale tile left after a chart was detached. Because the result is identical, a save doesn't reveal whether a chart you can't read exists.
This is stacked on #45538 and changes its behaviour for that one case. #45538 returns 422 for such a chart; this PR leaves it unlinked as a placeholder instead.
PUT(bothjson_metadata.positionsand rawposition_json),POST, and the copy endpoint, which the MCPduplicate_dashboardtool also uses.TESTING INSTRUCTIONS
pytest tests/unit_tests/dao/dashboard_test.py tests/unit_tests/mcp_service/dashboard/tool/test_duplicate_dashboard.pypytest tests/integration_tests/dashboards/api_tests.py -k "layout_chart_access or matches_missing_chart or layout_detached_chart"ADDITIONAL INFORMATION