rusackas opened a new pull request, #40816: URL: https://github.com/apache/superset/pull/40816
### SUMMARY This is a **test-only PR** opened as a TDD-style validation of issue #32966. #32966 (a reopen of #15457) reports that creating a dashboard through the REST API (`POST /api/v1/dashboard/`) with a `position_json` that references charts returns 200/201 but produces a **non-functional** dashboard — each chart renders *"There is no chart definition associated with this component, could it have been deleted?"*. The workaround is to open the dashboard in the UI, make any edit, and save — after which the charts appear. Root cause: `CreateDashboardCommand.run()` (`superset/commands/dashboard/create.py`) stores `position_json` verbatim and calls `DashboardDAO.create()`, but never calls `DashboardDAO.set_dash_metadata()`. That method is what extracts `chartId`s from the positions and populates the `dashboard.slices` relationship. `UpdateDashboardCommand.run()` **does** call it — which is exactly why a UI edit-and-save "fixes" the dashboard. So a dashboard created via the API has an empty `slices` relationship and the charts are never linked. This PR adds one regression test on the dashboard create API: 1. **`test_create_dashboard_via_api_links_charts_from_positions`** — inserts a chart, POSTs a new dashboard whose `position_json`/`json_metadata` references that chart, then asserts the chart id is present in the persisted `dashboard.slices`. It fails today because the slice relationship is left empty at create time. ### How to interpret CI - **CI green** → the create path links the referenced charts; merging closes #32966 and locks in the regression guard. - **CI red** → the bug is still live. Likely fix: mirror the `set_dash_metadata` call from `superset/commands/dashboard/update.py` in `create.py` so created dashboards populate `dashboard.slices` from `json_metadata.positions`. ### BEFORE/AFTER N/A — test-only change. ### TESTING INSTRUCTIONS ```bash pytest tests/integration_tests/dashboards/api_tests.py::TestDashboardApi::test_create_dashboard_via_api_links_charts_from_positions -v ``` ### ADDITIONAL INFORMATION - [x] Has associated issue: closes #32966 - [ ] Required feature flags: - [ ] 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]
