Kunal8954 opened a new pull request, #44169:
URL: https://github.com/apache/superset/pull/44169
### SUMMARY
Fixes #44167 — charts backed by a SIP-182 **semantic view** render
successfully in Explore but fail to save with a 422
`{"message":{"datasource_type":["Datasource type is invalid"]}}`.
**Root cause.** The datasource-type validation in
`CreateChartCommand`/`UpdateChartCommand` introduced by #43500 (to reject
`saved_query`/`query`, which `Slice.datasource` can never resolve) was written
as a TABLE-only check. That unintentionally also rejects `semantic_view`, even
though semantic views are a first-class, resolvable datasource
(`Slice.semantic_view`, `DatasourceType.SEMANTIC_VIEW`).
**Fix.** Extend the guard to an explicit allowlist of exactly the datasource
types `Slice` can resolve:
- `table` — unchanged, still accepted
- `semantic_view` — newly accepted
- `saved_query`, `query`, and unknown types — still rejected with the
existing `DatasourceTypeInvalidError` (422)
The fix is deliberately narrow: it does not accept arbitrary non-table
datasource types, does not normalize datasource types, and does not change any
datasource representation.
**Tests.**
- Unit: `CreateChartCommand` and `UpdateChartCommand` accept a
`semantic_view` datasource (validation reaches `get_datasource_by_id`,
`datasource_name` is populated); `saved_query`/`query`/`bogus` remain rejected
in both create and update paths.
- Integration API: `POST /api/v1/chart/` with
`datasource_type="semantic_view"` against a real semantic view row creates the
chart (201), mirroring the existing `saved_query` rejection test's API shape.
Honest caveat: the integration API test could **not** be run locally because
this environment lacks a running Redis cache and the seeded integration test
setup; it is left to CI. The relevant unit tests (29 passed) and all
`pre-commit run` checks (mypy, ruff, ruff-format, pylint, etc.) passed locally.
### BEFORE/AFTER
Before: `POST /api/v1/chart/` with `datasource_type: "semantic_view"` → 422
`Datasource type is invalid`.
After: the chart saves successfully (201).
### TESTING INSTRUCTIONS
```
pytest tests/unit_tests/commands/chart/create_test.py
tests/unit_tests/commands/chart/update_test.py
```
Integration (CI):
`tests/integration_tests/charts/api_tests.py::TestChartApi::test_create_chart_from_semantic_view`
### ADDITIONAL INFORMATION
- Has associated issue: Fixes #44167
- Backward compatible: only widens acceptance by the one
explicitly-supported `semantic_view` type; all previously invalid types remain
invalid.
--
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]