Skip to content

fix(dashboard): include semantic views in the dashboard datasets payload so semantic charts render their errors - #44413

Merged
rusackas merged 7 commits into
apache:masterfrom
mikebridge:sc-121353-dashboard-datasets-semantic
Sep 21, 2026
Merged

rusackas merged 7 commits into
apache:masterfrom
mikebridge:sc-121353-dashboard-datasets-semantic

Conversation

@mikebridge

Copy link
Copy Markdown
Member

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) is
type-aware, including parent semantic-layer grants, with sc-119501 coverage in
tests/unit_tests/dashboards/semantic_view_access_test.py and
tests/unit_tests/security/manager_test.py. New serializer access tests mock
can_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

  • Has associated issue: SC-121353
  • Required feature flags: no new flag; existing semantic-view setup required
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

Known follow-ups, deliberately outside this endpoint fix:

  • Align SemanticView.uid (provider identity) with the host id__type convention
    across consumers. exploreReducer.ts:293 has the same latent mismatch; changing
    model UID globally is a provider-contract change, not made here.
  • Embedded-guest/promiscuous chart-data membership gate (security/manager.py:4960)
    compares table-only slc.datasource; Dashboard.datasources is also table-only.
    This metadata fix does not resolve those chart-data/drill/thumbnail assumptions.
  • Chart export still uses model.table/table dataset UUIDs; semantic export is not
    introduced by this PR.
  • New import edge models.dashboard → semantic_layers.models (also used by API
    serializer): 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.

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).
@github-actions github-actions Bot added the api Related to the REST API label Sep 18, 2026
@netlify

netlify Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 8d3195d
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6aaec28b812cd80009b87c96
😎 Deploy Preview https://deploy-preview-44413--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.55172% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.65%. Comparing base (43fee87) to head (8d3195d).

Files with missing lines Patch % Lines
superset/models/dashboard.py 94.44% 0 Missing and 1 partial ⚠️
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              
Flag Coverage Δ
hive 37.15% <25.92%> (-0.01%) ⬇️
javascript 76.10% <100.00%> (-0.01%) ⬇️
mysql 56.37% <59.25%> (-0.01%) ⬇️
postgres 56.39% <59.25%> (-0.02%) ⬇️
presto 39.03% <25.92%> (-0.01%) ⬇️
python 84.96% <96.29%> (+<0.01%) ⬆️
sqlite 56.10% <59.25%> (-0.01%) ⬇️
unit 76.79% <96.29%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread superset/models/dashboard.py Resolved
@bito-code-review

Copy link
Copy Markdown
Contributor

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 test_dashboard_datasets_isolate_semantic_provider_failure and test_dashboard_table_serialization_failure_is_not_suppressed, which verify that provider isolation does not swallow errors for tables or semantic views.

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 (which was not fully visible in the provided diff hunk) correctly implements the logic tested in these new test cases.

superset/models/dashboard.py

@pytest.mark.parametrize("error_type", [ValueError, RuntimeError])
def test_dashboard_datasets_isolate_semantic_provider_failure(
    semantic_view: SemanticView,
    error_type: type[Exception],
    caplog: pytest.LogCaptureFixture,
) -> None:
    """A failed provider must not hide a mixed dashboard's table metadata."""

Publish the four semantic metadata properties added by SC-121353 so generated API documentation matches DashboardDatasetSchema and the drift check.
@github-actions github-actions Bot added the doc Namespace | Anything related to documentation label Sep 18, 2026

@bito-code-review bito-code-review Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Agent Run #429390

Actionable Suggestions - 2
  • superset/dashboards/api.py - 1
  • superset/models/dashboard.py - 1
Additional Suggestions - 4
  • superset-frontend/src/components/Chart/Chart.tsx - 1
    • Guard/display key mismatch · Line 297-297
      The 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-166
      Test 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-41
      The 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-345
      These 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

AI Code Review powered by Bito Logo

Comment thread superset/dashboards/api.py Resolved
Comment thread superset/models/dashboard.py Resolved
…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 richardfogaca left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Exception around SemanticView.data also 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 guest datasets allowlist 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.

@bito-code-review

bito-code-review Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #b42df9

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: aa20f81..33ccf0a
    • superset/models/dashboard.py
    • tests/unit_tests/dashboards/datasets_test.py
  • Files skipped - 1
    • docs/static/resources/openapi.json - Reason: Filter setting
  • 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

AI Code Review powered by Bito Logo

…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.
@mikebridge

Copy link
Copy Markdown
Member Author

Thanks @richardfogaca — addressed both access-boundary items from your review in a04fe1ef5805.

  1. Semantic views are checked before provider discovery; denied views return a minimal persisted-field stub. The real denial-path regression asserts zero provider instantiation/calls. It also caught discovery inside permission-error construction, which now reads the persisted datasource ID instead of datasource.data.
  2. Both parent and semantic_view_features are removed for inaccessible callers and guest serialization. The narrowing assertions are flipped, with a real GuestUser schema case (not an HTTP token-acceptance claim).

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 gabotorresruiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, daos and security: 1589 passed.
  • Red first: I put superset/models/dashboard.py, superset/dashboards/api.py, superset/dashboards/schemas.py and superset/security/manager.py back to 394bca55c7 and reran tests/unit_tests/dashboards/datasets_test.py. 10 of 13 fail there, and test_dashboard_datasets_include_semantic_view fails with assert 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/datasets returns {"result": []} on 394bca55c7 and a payload keyed 1__semantic_view on this head. With a table and a semantic view both at id 1, the response carries ['1__semantic_view', '1__table'], so keyBy(action.datasources, 'uid') in src/dashboard/reducers/datasources.ts gives them separate slots.
  • Denial path: with can_access_datasource false the response is {"id", "name", "supports_drill_to_detail", "supports_samples", "type", "uid"} and the provider mock records zero calls. The datasource.data["id"] to datasource.id change in get_datasource_access_error_object is what makes that hold; without it, building the denial error would have run discovery by itself.
  • Guest path with a real GuestUser through the route: no parent, no semantic_view_features, no database, no perm, no sql, no edit_url.

Frontend

  • src/components/Chart/Chart.test.tsx: 5 passed. Wider sweep over src/dashboard/reducers, src/dashboard/actions, src/components/Chart, FilterBar, FiltersBadge and gridComponents/Chart: 61 suites, 607 passed, 2 skipped, 2 failed. The two failures (FilterBar apply button is disabled after creating a filter and DrillByModal › 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."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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', () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bito-code-review

bito-code-review Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #e6864e

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset-frontend/src/components/Chart/Chart.test.tsx - 1
    • Duplicate test logic · Line 134-162
      This test duplicates the one at lines 110-132: both pass `queriesResponse=[{message:'Semantic result...'}]`, so `queryResponse.message` short-circuits the guard in `renderErrorMessage` (Chart.tsx:295-302) identically. The differing `datasource`/`datasetsStatus` props never change the exercised path, so the new test adds no coverage. Make it assert a distinct branch or remove it.
Review Details
  • Files reviewed - 8 · Commit Range: 33ccf0a..f7eb3d3
    • 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
    • superset/security/manager.py
    • tests/unit_tests/dashboards/datasets_test.py
    • tests/unit_tests/security/test_permission_instructions_link.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

AI Code Review powered by Bito Logo

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 gabotorresruiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_parent now builds a real SqlaTable with a Database and serializes table.data_for_slices([chart]), pinning the exact key set plus parent and both capability values. Against 43fee87672 it fails on the missing parent and supports_drill_to_detail, so datasets_test.py goes 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 loads is red without the Chart.tsx change. I reverted Chart.tsx to 43fee87672 (byte identical to 394bca55c7) and both new tests fail, on different branches: the loading one renders loading-indicator, this one renders Stale client-side rendering error. So it does cover the queryResponse?.message || chartAlert precedence, 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 rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@rusackas
rusackas merged commit 298d776 into apache:master Sep 21, 2026
83 checks passed
villebro pushed a commit that referenced this pull request Sep 22, 2026
…oad so semantic charts render their errors (#44413)

(cherry picked from commit 298d776)
villebro added a commit that referenced this pull request Sep 23, 2026
On master, #44413 also serializes semantic_view_features, a field that only
#42540 (derive Explore picker modes from semantic view features) produces.
#42540 isn't on 7.0, so the field is never populated here and the test
expecting it fails. The rest of the #44413 fix is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Related to the REST API doc Namespace | Anything related to documentation size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants