Repository navigation
fix(dashboard): include semantic views in the dashboard datasets payload so semantic charts render their errors - #44413
Conversation
Resolve dashboard metadata by datasource type, preserve semantic capabilities, and normalize payload identity at the API boundary. Isolate provider metadata failures so unrelated datasets remain usable and show backend errors while metadata is unavailable. Regressions cover colliding ids, provider failures, capabilities, and message-only chart errors (SC-121353).
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #44413 +/- ##
==========================================
- Coverage 80.65% 80.65% -0.01%
==========================================
Files 2942 2942
Lines 175692 175713 +21
Branches 40788 40792 +4
==========================================
+ Hits 141705 141720 +15
- Misses 31325 31331 +6
Partials 2662 2662
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:
|
|
The flagged issue correctly identifies a potential risk where semantic serialization exceptions are swallowed, which could lead to silent failures. The PR already includes tests that address this, specifically Since the PR already implements tests to ensure these errors are not suppressed, the issue appears to be addressed by the existing changes. I recommend verifying that the implementation code in superset/models/dashboard.py |
Publish the four semantic metadata properties added by SC-121353 so generated API documentation matches DashboardDatasetSchema and the drift check.
There was a problem hiding this comment.
Code Review Agent Run #429390
Actionable Suggestions - 2
-
superset/dashboards/api.py - 1
- Duplicated uid format string · Line 762-762
-
superset/models/dashboard.py - 1
- CWE-755: Broad Catch Masks Errors · Line 369-371
Additional Suggestions - 4
-
superset-frontend/src/components/Chart/Chart.tsx - 1
-
Guard/display key mismatch · Line 297-297The new `!queryResponse?.message` guard suppresses the spinner, but `subtitle` is `chartAlert || queryResponse?.message` (line 290), so when `chartAlert` is set to a different value the backend message is masked and never shown, contradicting the 'always show backend API errors' intent. Consider preferring `queryResponse?.message` in the subtitle so the guard and display key on the same source.
-
-
superset-frontend/src/components/Chart/Chart.test.tsx - 1
-
Redundant duplicate test · Line 133-166Test 2 duplicates test 1: both pass a truthy `queriesResponse[0].message`, so in `renderErrorMessage` (Chart.tsx:295-302) the `!queryResponse?.message` guard is false in both and both render `ChartErrorMessage` via the same branch. The differing `datasource`/`datasetsStatus` never changes the branch taken, so the 'after the dashboard supplies the real datasource' scenario isn't actually exercised.
-
-
tests/unit_tests/dashboards/datasets_test.py - 1
-
Duplicated test setup block · Line 37-41The semantic-chart setup (`Slice(datasource_id=..., datasource_type="semantic_view")`, `chart.semantic_view = semantic_view`, `Dashboard(slices=[...])`) repeats verbatim in five tests (lines 37-41, 59-66, 90-94, 144-151, 186-191). Extracting a shared fixture beside `pytest_plugins` would keep chart/dashboard wiring in one place as `Slice` construction evolves.
-
-
superset/dashboards/schemas.py - 1
-
Inconsistent field declaration style · Line 342-345These four fields use `name: fields.Bool = fields.Bool()` while the ~36 sibling fields in `DashboardDatasetSchema` (e.g. `id`, `filter_select`, `normalize_columns`) use plain `name = fields.Bool()`. The annotation merely restates the assigned field type and adds no information, and the split style within one class body raises cognitive load. marshmallow treats both forms identically, so aligning with the file's plain style is behavior-neutral.
-
Review Details
-
Files reviewed - 6 · Commit Range:
aa20f81..aa20f81- superset-frontend/src/components/Chart/Chart.test.tsx
- superset-frontend/src/components/Chart/Chart.tsx
- superset/dashboards/api.py
- superset/dashboards/schemas.py
- superset/models/dashboard.py
- tests/unit_tests/dashboards/datasets_test.py
-
Files skipped - 0
-
Tools
- MyPy (Static Code Analysis) - ✔︎ Successful
- Astral Ruff (Static Code Analysis) - ✔︎ Successful
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers an incremental AI Review. -
/review full- Manually triggers a full AI Review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].
Documentation & Help
…ails Preserve provider-failure isolation because providers have no shared operational exception contract. Log persisted identity and exception class only, never provider uid, message or traceback. Cover AttributeError alongside provider failures per the owner decision on apache#44413.
richardfogaca
left a comment
There was a problem hiding this comment.
Richard's agent here:
Reviewed 33ccf0a3fa. The id-collision handling is solid (backend groups by type and id, the API rewrites uid to <id>__semantic_view, Redux keys by uid), the serialized semantic payload does not carry more than the table payload, and the access gate is type-aware. Two things before I can approve, both on the access boundary.
1. Important: provider discovery runs before the access check. Dashboard.datasets_trimmed_for_slices calls datasource.data_for_slices(...) for every semantic view on the dashboard, and SemanticView.data instantiates the provider and runs get_metrics() / get_dimensions() discovery with the layer's stored credentials. Only afterwards does _serialize_dashboard_dataset call can_access_datasource and strip the result. So a user with dashboard access and no view or layer grant triggers remote discovery on every GET /datasets, and the output is thrown away. For tables data_for_slices is a local metadata read, so this is new exposure. Could we check can_access_datasource first and skip discovery for views the caller cannot access?
2. Important: the new fields bypass both narrowing lists. parent (the semantic layer name) and semantic_view_features are in neither DASHBOARD_DATASET_INACCESSIBLE_FIELDS nor the guest post_dump pops, while the table analogue database is dropped in both. A dashboard-only user or a guest token still receives the layer name, and datasets_test.py currently asserts parent is present when can_access is false, which cements it. Low severity, but it contradicts the fail-closed contract the rest of the endpoint follows. Small suggestion: add parent (and arguably semantic_view_features) to both lists and flip that assertion.
Observations, non-blocking:
- The
except ExceptionaroundSemanticView.dataalso swallows programming errors and logs only the class name; a broken view silently disappears and its charts sit on the placeholder datasource. Your thread answers hold at head, so this is just noting the trade-off. - Embedded/guest semantic charts still cannot work regardless of this PR: the chart-membership leg uses the table-only
slc.datasource, and the guestdatasetsallowlist compares bare ids across types. You already list that as a follow-up.
Verified with no issues: sql, select_star, params, template_params, and fetch_values_predicate are None for views, metrics[].expression is dropped with metrics when inaccessible, perm is dropped for guest and inaccessible cases, the openapi.json additions match the schema, and the Chart.tsx guard still suppresses JS errors while datasets load. CI is green on this head.
Code Review Agent Run #b42df9Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
…metadata Address Richard's access-boundary review: return a persisted-field stub before provider discovery for denied views, and redact parent/features for denied and guest callers. Read persisted IDs when constructing permission errors so denial itself cannot invoke discovery. Prefer backend error messages over stale client alerts and make the metadata-loading regressions independent. Preserve safe provider failure isolation and host datasource identity.
|
Thanks @richardfogaca — addressed both access-boundary items from your review in a04fe1ef5805.
The backend-message precedence and independent real-datasource frontend regression are also corrected. Safe provider isolation/logging and the host id__type key remain unchanged. Scoped verification: 50 backend tests and 5 Chart tests passed; main MyPy and other applicable hooks passed. Independent exact-tree review found zero issues; source-resolved TypeScript passed with no diagnostics. The packaged-declaration hook failure was isolated to the missing-declaration environment; new-head CI remains the integration gate. Acknowledged the broad-catch trade-off and deferred embedded semantic support. SC-121338 is related provider validation-error mapping work, not full coverage of the discovery exception contract. Separate discovery-exception, typed guest-membership and shared host-key follow-ups are proposed in the handoff; no duplicate tickets or scope expansion in this repair. |
gabotorresruiz
left a comment
There was a problem hiding this comment.
LGTM. This closes the gap properly rather than papering over it: the grouping keys on (datasource_type, datasource_id), resolution goes through Slice.resolved_datasource instead of the table-only Slice.datasource, the return type widens to BaseDatasource | SemanticView, and the <id>__<type> key is normalized at the serialization boundary instead of mutating SemanticView.uid, which is the provider's own identity. Slice.data writes form_data["datasource"] as f"{datasource_id}__{datasource_type}" (superset/models/slice.py:395) and src/dashboard/components/gridComponents/Chart/Chart.tsx:248 reads the store by exactly that string, so the rewrite lands on the key the reducer needs.
What I verified on a04fe1ef58, in an isolated worktree with a fresh venv.
Backend
tests/unit_tests/dashboards,semantic_layers,models,daosandsecurity: 1589 passed.- Red first: I put
superset/models/dashboard.py,superset/dashboards/api.py,superset/dashboards/schemas.pyandsuperset/security/manager.pyback to394bca55c7and rerantests/unit_tests/dashboards/datasets_test.py. 10 of 13 fail there, andtest_dashboard_datasets_include_semantic_viewfails withassert 0 == 1 where 0 = len([]), which is the reported symptom exactly. - Through the route, not only the model: for a dashboard whose only chart is a semantic view,
GET /api/v1/dashboard/1/datasetsreturns{"result": []}on394bca55c7and a payload keyed1__semantic_viewon this head. With a table and a semantic view both at id1, the response carries['1__semantic_view', '1__table'], sokeyBy(action.datasources, 'uid')insrc/dashboard/reducers/datasources.tsgives them separate slots. - Denial path: with
can_access_datasourcefalse the response is{"id", "name", "supports_drill_to_detail", "supports_samples", "type", "uid"}and the provider mock records zero calls. Thedatasource.data["id"]todatasource.idchange inget_datasource_access_error_objectis what makes that hold; without it, building the denial error would have run discovery by itself. - Guest path with a real
GuestUserthrough the route: noparent, nosemantic_view_features, nodatabase, noperm, nosql, noedit_url.
Frontend
src/components/Chart/Chart.test.tsx: 5 passed. Wider sweep oversrc/dashboard/reducers,src/dashboard/actions,src/components/Chart,FilterBar,FiltersBadgeandgridComponents/Chart: 61 suites, 607 passed, 2 skipped, 2 failed. The two failures (FilterBar apply button is disabled after creating a filterandDrillByModal › should maintain table state when switching between Chart and Table views) are 20s timeouts under a parallel run; both pass with--runInBand, and the sharded CI job is green on this head.
Coordination note
#44169 rewrites the same hunk in datasets_trimmed_for_slices: it adopts the (datasource_type, datasource_id) key but keeps the table-only slc.datasource plus isinstance(datasource, BaseDatasource), so it still resolves to an empty list for a semantic chart. The two will conflict textually and this one supersedes that hunk, so it is worth sequencing them deliberately.
Two non-blocking comments inline. Separately, several links in the description resolve only inside a private tracker or a private repo, so they are dead ends for anyone reading this repo; worth trimming the description to context a reader here can follow.
|
|
||
|
|
||
| def test_dashboard_table_serialization_omits_absent_semantic_fields() -> None: | ||
| """Adding optional capability fields must not change legacy table payloads.""" |
There was a problem hiding this comment.
Not a blocker: this docstring overstates what the test proves, and the opposite is true. payload is a hand-built {"id", "uid", "type"} dict, so the three new schema fields have nothing to serialize; a real table payload does change.
I hit GET /api/v1/dashboard/<id>/datasets for a table-only dashboard on 394bca55c7 and on this head. Base returns ['columns', 'database', 'id', 'metrics', 'name', 'type', 'uid']; this head returns those plus parent, supports_samples and supports_drill_to_detail, because SqlaTable.data already emits all three (superset/connectors/sqla/models.py:482, :507, :508) and DashboardDatasetSchema now declares them.
I could not find anything that breaks: parent.name is the database name already exposed through database.name, both are popped for guests and for callers without datasource access, and supports_* are class constants that are always True on SqlaTable while useDrillDetailMenuItems only reacts to === false. It is still a response shape change on every table dataset. Could we feed this test a real data_for_slices payload and assert the exact key set, so the contract is pinned instead of contradicted?
There was a problem hiding this comment.
Addressed in f7eb3d3 — you are right: the old fixture/docstring did not prove an unchanged table response. The test now calls real SqlaTable.data_for_slices with a Database/Slice fixture, serializes it, and pins the exact key set plus parent and both capability values. 50 affected backend tests pass. The companion Chart tests also have a verified base-revert control (2 fail with Chart.tsx from 394bca5; all 5 pass when restored). Thanks.
| ).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('shows a semantic error after the dashboard supplies the real datasource', () => { |
There was a problem hiding this comment.
Small note, not a blocker: this one is green without the Chart.tsx change. I reverted Chart.tsx to 394bca55c7 and reran the file; only shows a message-only semantic API error while datasource metadata is loading fails, this test passes. With queriesResponse: [{}] there is no message, so subtitle resolves to chartAlert under both the old and the new precedence, and a real datasource already skipped the loading guard before this change.
Worth keeping as an invariant, but it is not a regression for this fix, and the uid assertion is self-fulfilling because the test hands datasourcesReducer the 1__semantic_view key it then asserts on.
There was a problem hiding this comment.
Addressed in f7eb3d3 — the loaded-datasource test now supplies a competing API message and stale chartAlert, asserting the API message wins and the stale alert is absent. Removed the self-fulfilling reducer/UID assertion. Verified Chart.tsx exactly matched the 394bca5 blob during the control: both the loading case and this revised loaded case fail (2 failed, 3 passed). Restoring Chart.tsx gives 5/5 passing. No production changes in this commit. Thanks.
Code Review Agent Run #e6864eActionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Incorporate the master unit-test repair and type-aware datasource membership. Verified access-before-discovery and guest metadata narrowing on the merged tree; independent access review approved the exact snapshot.
gabotorresruiz
left a comment
There was a problem hiding this comment.
LGTM, re-approving so the approval covers 8d3195df63.
Both notes from my last pass are addressed, and I checked them by running rather than by reading the commit message.
test_dashboard_table_serialization_includes_capabilities_and_parentnow builds a realSqlaTablewith aDatabaseand serializestable.data_for_slices([chart]), pinning the exact key set plusparentand both capability values. Against43fee87672it fails on the missingparentandsupports_drill_to_detail, sodatasets_test.pygoes from 10 to 11 of 13 red on the base. It is a regression test now instead of an assertion of the opposite.prefers the semantic API error over a stale alert after datasource metadata loadsis red without theChart.tsxchange. I revertedChart.tsxto43fee87672(byte identical to394bca55c7) and both new tests fail, on different branches: the loading one rendersloading-indicator, this one rendersStale client-side rendering error. So it does cover thequeryResponse?.message || chartAlertprecedence, which the loading test never reaches.
No production file moved on the PR side since a04fe1ef58. superset/models/dashboard.py and superset/security/manager.py differ only because the merge pulled #43848 in, and that lands has_member_datasource at superset/models/dashboard.py:279, well clear of datasets_trimmed_for_slices at :376. I redid the route checks on this head anyway: semantic view keyed 1__semantic_view with supports_drill_to_detail: false, denial returns the six-field stub with zero provider calls, a table and a semantic view both at id 1 come back as ['1__semantic_view', '1__table'], the guest payload carries no parent, semantic_view_features, database, perm, sql or edit_url, and a raising provider leaves ['2__table'] with a WARNING carrying only the view id, layer uuid and exception class. tests/unit_tests/dashboards, semantic_layers, models, daos and security: 1750 passed. Chart.test.tsx: 5 passed. CI is green on this head.
Worth sequencing deliberately with #44169
#44169 is approved now and still carries its own rewrite of datasets_trimmed_for_slices. git merge-tree on the two heads reports CONFLICT (content) in superset/models/dashboard.py, and it is an awkward one: the composite key line, the widened list[tuple[BaseDatasource | SemanticView, ...]] annotation and the try/except isolation block all auto merge, so only the loop header conflicts. Resolving that header toward #44169 yields a function that still reads as semantic-aware but resolves through the table-only slc.datasource under isinstance(datasource, BaseDatasource), which drops semantic views from the payload again and leaves the except SemanticView branch unreachable. I built that exact resolution and ran it: 10 of 13 in datasets_test.py fail, so CI does catch it.
The other half is that #44169's own test_datasets_trimmed_for_slices_keeps_colliding_ids_separate does not survive this change either. I ran it against this head and it returns [], because it sets datasource on a bare Mock slice while datasets_trimmed_for_slices here reads Slice.resolved_datasource, which returns slc.table for datasource_type == "table" (superset/models/slice.py:254). So whoever merges second has to update that test as well as resolve the markers. Dropping the datasets_trimmed_for_slices hunk from #44169 once this lands looks like the cleanest way through.
rusackas
left a comment
There was a problem hiding this comment.
Heya @mikebridge, traced the access-control side of this end to end since it touches security/manager.py. The .data["id"] to .id swap is more than cosmetic, SemanticView.data triggers live provider discovery, so the old code was calling out to the provider (with stored credentials) just to build a denial message. Good catch. The (datasource_type, datasource_id) keying fix also closes a real bug, a table and a semantic view sharing an id used to collide in the old dict.
The broad except Exception in datasets_trimmed_for_slices is fine as scoped, checked SemanticView.data/data_for_slices and there's no raise_for_access path inside that chain today, so it isn't swallowing an auth decision, just failing safe on a provider hiccup. Worth narrowing once providers get a shared exception contract, but that's a fair follow-up rather than something to hold this on.
@gabotorresruiz, both of your threads look genuinely addressed in f7eb3d3, might be worth clicking them resolved. Approving.
SUMMARY
Fix SC-121353: dashboard datasets
metadata resolves charts by datasource type, includes semantic views, and isolates
provider discovery failures so a broken view does not hide table metadata.
Semantic capability fields reach the dashboard store; message-only backend errors
render instead of a loading indicator. Semantic payload UID is normalized only at
the API serialization boundary to match the chart datasource key.
Related: SC-120295,
superset-shell#5140,
#44269,
#43848.
Access policy unchanged: existing
raise_for_access(datasource=SemanticView)istype-aware, including parent semantic-layer grants, with sc-119501 coverage in
tests/unit_tests/dashboards/semantic_view_access_test.pyandtests/unit_tests/security/manager_test.py. New serializer access tests mockcan_access_datasource: they prove narrowing wiring, not the underlying gate.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
No browser capture. Before: semantic metadata omitted, message-only backend errors
could remain a spinner. After: semantic metadata and capabilities reach the store;
message-only errors render. Verified via backend and React unit tests, not live
provider or embedded-browser acceptance.
TESTING INSTRUCTIONS
Automated: affected dashboards/semantic-layer/model/DAO suites (630 passed), Chart
Jest (5 passed), source-resolved targeted tsc (exit 0). Controls reproduced provider
exceptions, lost capability fields, incorrect UID boundary and actual enum TS2322.
MyPy/other applicable hooks pass. The configured frontend type hook still lacks
built workspace declarations; the source-resolved lane uses existing source paths,
references dropped, without declaration copies. Exact-head CI must build packages.
Manual follow-up: load a dashboard with both a table-backed and semantic chart.
Confirm distinct metadata when ids match; simulate provider discovery failure and
confirm table metadata remains. Confirm semantic charts do not offer unsupported
drill-to-detail and show a message-only chart-data failure. Do not enable shared flags.
ADDITIONAL INFORMATION
Known follow-ups, deliberately outside this endpoint fix:
SemanticView.uid(provider identity) with the hostid__typeconventionacross consumers.
exploreReducer.ts:293has the same latent mismatch; changingmodel UID globally is a provider-contract change, not made here.
security/manager.py:4960)compares table-only
slc.datasource;Dashboard.datasourcesis also table-only.This metadata fix does not resolve those chart-data/drill/thumbnail assumptions.
model.table/table dataset UUIDs; semantic export is notintroduced by this PR.
models.dashboard → semantic_layers.models(also used by APIserializer): safe in the checked initialization graph because the datasource DAO
already imports SemanticView; keep this edge in mind in future cycle refactors.
Independent final-source re-check approved the published source tree; exact-head CI
and maintainer review remain before merge.