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

   ### SUMMARY
   
   Reject unsafe full `position_json` replacements in the MCP 
`update_dashboard` tool before they overwrite a valid saved layout.
   
   Superset renders only layout nodes reachable from `ROOT_ID`, but dashboard 
hydration indexes every `CHART` node in `position_json`. An unreachable chart 
therefore prevents the normal missing-chart fallback while remaining invisible, 
which can leave a dashboard blank even though the chart nodes and slice 
associations still exist.
   
   This change validates graph references, cycles, component IDs, parent paths, 
and root shape. It also requires the reachable chart IDs to exactly match the 
charts associated with the dashboard. Invalid updates return 
`InvalidDashboardLayout` before any mutation or commit, preserving the previous 
layout.
   
   The validator handles Superset's two reserved exceptions: detached 
`HEADER_ID`, and the empty detached `GRID_ID` retained by top-level tab layouts.
   
   Tracking: [SC-117987](https://app.shortcut.com/preset/story/117987) 
`[sc-117987]`
   
   Related: #43133 contains generate-only fallback validation as part of native 
AI authoring. This PR addresses the existing `update_dashboard` data-loss path 
and rejects unreachable nodes that the validator currently proposed there does 
not detect.
   
   ### TESTING INSTRUCTIONS
   
   - `ruff check superset/mcp_service/dashboard/layout_validation.py 
superset/mcp_service/dashboard/tool/update_dashboard.py 
tests/unit_tests/mcp_service/dashboard/test_layout_validation.py 
tests/unit_tests/mcp_service/dashboard/tool/test_update_dashboard.py`
   - `ruff format --check superset/mcp_service/dashboard/layout_validation.py 
superset/mcp_service/dashboard/tool/update_dashboard.py 
tests/unit_tests/mcp_service/dashboard/test_layout_validation.py 
tests/unit_tests/mcp_service/dashboard/tool/test_update_dashboard.py`
   - `git diff --check`
   - Standalone smoke test for valid top-level tabs and unreachable chart 
rejection passed.
   - Targeted pytest collection is currently blocked in this worktree by the 
installed `sqlglot` version (`ModuleNotFoundError: 
sqlglot.dialects.singlestore`) before these tests load.
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: 
[SC-117987](https://app.shortcut.com/preset/story/117987)
   - [ ] 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]

Reply via email to