Skip to content

fix(chart): allow semantic view datasource when saving charts - #44169

Merged
rusackas merged 19 commits into
apache:masterfrom
Kunal8954:fix/44167-allow-semantic-view-chart-save
Sep 23, 2026
Merged

rusackas merged 19 commits into
apache:masterfrom
Kunal8954:fix/44167-allow-semantic-view-chart-save

Conversation

@Kunal8954

Copy link
Copy Markdown
Contributor

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

@bito-code-review

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

Copy link
Copy Markdown
Contributor

Code Review Agent Run #4e6076

Actionable Suggestions - 0
Additional Suggestions - 3
  • superset/commands/chart/update.py - 1
    • Semantic view charts unsupported downstream · Line 239-242
      Allowing `SEMANTIC_VIEW` here contradicts the comment's own rationale: `Slice.datasource` (slice.py:193) returns only `self.table`, so a semantic-view chart yields `datasource == None`. Dashboard rendering (`datasets_trimmed_for_slices`, `slc.datasource.schema`/`.database.name`) and security access checks (`chart.datasource`) will drop or crash on it. Update `Slice.datasource` and consumers, or keep TABLE-only.
  • tests/unit_tests/commands/chart/update_test.py - 1
    • Inline import in test body · Line 290-290
      The `SemanticView` import is placed inline inside the test body. Per the repo's module-level import convention, move it to the top of the file alongside the other `superset.*` imports; inline imports are only justified for documented circular dependencies.
  • tests/unit_tests/commands/chart/create_test.py - 1
    • Hoist inline import · Line 130-130
      The inline `from superset.semantic_layers.models import SemanticView` inside the test body can be hoisted to the module-level imports. Inline imports are only preferred when avoiding a circular dependency, which isn't the case here.
Review Details
  • Files reviewed - 5 · Commit Range: d159207..d159207
    • superset/commands/chart/create.py
    • superset/commands/chart/update.py
    • tests/integration_tests/charts/api_tests.py
    • tests/unit_tests/commands/chart/create_test.py
    • tests/unit_tests/commands/chart/update_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

@netlify

netlify Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit ca7c2a6
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6ab3a795d75b36000876ed52
😎 Deploy Preview https://deploy-preview-44169--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 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.01%. Comparing base (7c7b3ad) to head (411340c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #44169      +/-   ##
==========================================
- Coverage   81.02%   81.01%   -0.02%     
==========================================
  Files        2952     2951       -1     
  Lines      177950   177832     -118     
  Branches    41248    41206      -42     
==========================================
- Hits       144183   144068     -115     
+ Misses      31049    31047       -2     
+ Partials     2718     2717       -1     
Flag Coverage Δ
hive 36.84% <0.00%> (-0.01%) ⬇️
mysql 55.99% <0.00%> (-0.01%) ⬇️
postgres 56.00% <0.00%> (-0.01%) ⬇️
presto 38.77% <0.00%> (-0.01%) ⬇️
python 85.31% <100.00%> (+<0.01%) ⬆️
sqlite 55.72% <0.00%> (-0.01%) ⬇️
unit 77.59% <100.00%> (+<0.01%) ⬆️

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/commands/chart/create.py Resolved
Comment thread superset/commands/chart/update.py Resolved
@Kunal8954

Copy link
Copy Markdown
Contributor Author

The Python-Unit workflow was cancelled after all tests completed successfully (15131 passed, 5 skipped, 2 xfailed). The required check is failing only because the upstream job was cancelled. I’m unable to rerun the workflow with my contributor permissions. Could someone with maintainer access please rerun Python-Unit for this commit?

@rusackas

Copy link
Copy Markdown
Member

@Kunal8954 codeant's thread on this is still open: Slice.datasource only resolves self.table, so a semantic-view chart's .datasource comes back None. That breaks the security manager's access check for anyone who isn't chart owner/editor/admin, so the chart saves but non-privileged viewers can't open it. Needs a fix before this lands.

@bito-code-review

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

Copy link
Copy Markdown
Contributor

Code Review Agent Run #509a41

Actionable Suggestions - 0
Additional Suggestions - 4
  • superset/charts/filters.py - 1
    • Layer perm not honored · Line 183-192
      This no-viewer SEMANTIC_VIEW filter only checks Slice.perm, but access to a semantic view is also granted via its parent SemanticLayer.perm (see SemanticView.raise_for_access and DatasourceDAO.build_semantic_view_query, which accept either perm). Because set_related_perm copies only the view's perm into Slice.perm, a user granted at the layer level can open the view and see it in the datasource list, yet their chart is hidden here. Please join SemanticLayer (on Slice.datasource_id -> SemanticView.semantic_layer_uuid) and accept a chart when either Slice.perm or SemanticLayer.perm is in the user's datasource_access perms.
  • superset/models/slice.py - 2
    • AttributeError on semantic view · Line 203-206
      `datasource` now returns `SemanticView`, which has no `link` attribute (verified in `semantic_layers/models.py`). `datasource_link` (line 221) calls `datasource.link` directly, so a chart backed by a semantic view raises `AttributeError`. Note `datasource_url` already guards with `getattr(..., "explore_url", None)`; apply the same pattern here.
    • Eager subquery on every load · Line 172-180
      Both `table` and the new `semantic_view` relationship use `lazy="subquery"`, so every Slice load now issues an extra subquery against `semantic_views` even for table-backed slices. On a hot chart-loading path this adds avoidable work. Consider `lazy="select"` for the new relationship.
  • tests/unit_tests/charts/test_filters.py - 1
    • Test assertion not isolated · Line 228-228
      `'[layer].[view](id:1)'` also appears in the table branch: `get_dataset_access_filters` renders `Slice.perm.in_(perms)` (superset/utils/filters.py:39), and `_perms` returns the same perm for `datasource_access`. So this assertion passes even if the semantic-view branch regressed to a numeric-id join — the exact case the docstring claims to guard. Mock `get_dataset_access_filters` to `false()` to isolate the semantic-view subquery.
Review Details
  • Files reviewed - 7 · Commit Range: d159207..a5d5b0b
    • superset/charts/filters.py
    • superset/models/dashboard.py
    • superset/models/slice.py
    • tests/integration_tests/charts/api_tests.py
    • tests/unit_tests/charts/test_filters.py
    • tests/unit_tests/models/slice_test.py
    • tests/unit_tests/subjects/test_raise_for_access.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/models/slice.py Outdated
def datasource(self) -> SqlaTable | SemanticView | None:
if table := self.table:
return table
return self.semantic_view

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.

SECURITY FIX REQUIRED: Returning a SemanticView here feeds its integer ID into Dashboard.datasources, while can_drill_dataset_via_dashboard_access compares only bare IDs. A guest for a dashboard containing semantic view 7 can request /datasource/samples with table ID 7 and receive raw rows from the unrelated SqlaTable 7; can this keep table-only authorization callers type-pinned or compare (datasource_type, id)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I’ll keep the table-only authorization path type-pinned so a semantic-view ID cannot be treated as a table ID.

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.

While tracing this I found two more bare id comparisons the type pinning should cover in the same sweep: _guest_token_allows_dataset(chart.datasource.id ...) in the chart branch of raise_for_access, where a guest token's dataset allowlist of table ids is compared against a semantic view id, and the native filter arm of the datasource branch, which compares target.get("datasetId") from dashboard metadata against datasource.data["id"], where SemanticView.data["id"] is the bare integer id.

Comment thread superset/models/slice.py
remote_side="SqlaTable.id",
lazy="subquery",
)
semantic_view = relationship(

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.

Adding this non-FK relationship makes deletion-retention policy validation fail for every Slice: dependency discovery includes relationships without a physical FK, but purge_policy_registry only declares Slice.table, so get_purge_policy(Slice) raises an incomplete-policy error before purging even a table-backed chart. Should this declare semantic_view as PRESERVE and add purge coverage?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I’ll update the purge policy coverage for the new relationship and verify deletion-retention validation.

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.

Confirmed empirically: on this branch tests/unit_tests/commands/deletion_retention/ has 14 failures, all RuntimeError: Incomplete purge policy for Slice: missing=[relationship:slices->semantic_views:->:manytoone:semantic_view], and the same suite passes on the parent commit. Since get_purge_policy(Slice) raises, chart purging itself breaks, not just the validation tests.

Comment thread superset/commands/chart/create.py Outdated
if datasource_type != DatasourceType.TABLE:
if datasource_type not in {
DatasourceType.TABLE,
DatasourceType.SEMANTIC_VIEW,

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.

Charts saved through this new type cannot survive their own export/import flow: the exporter removes datasource_type and only emits dataset_uuid when model.table is set, while chart import requires dataset_uuid. A semantic-view chart therefore exports YAML without any datasource pointer and immediately fails re-import; can the portable format carry a semantic-view reference before this type is accepted?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I’ll check the chart export/import format and add semantic-view datasource references before keeping this type enabled.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Following up on this thread: chart export/import for semantic-view charts (emitting a semantic-view datasource reference from the exported chart config and resolving it on import) is tracked as a follow-up rather than landing with this fix, so this PR is not blocked on it here. Current changes keep chart-list access, rename cascades, and trimmed-datasource validation on the new type consistent in the meantime.

Comment thread superset/charts/filters.py Outdated
and_(
Slice.datasource_type == DatasourceType.SEMANTIC_VIEW,
~chart_has_viewers,
Slice.perm.in_(

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.

Chart visibility now depends on the stored Slice.perm, but the semantic-view and semantic-layer rename hooks update the view menu and SemanticView.perm without updating existing slices, unlike the dataset rename path. After either rename, users retain current datasource_access yet their saved charts disappear from the list; can this join the current permission or cascade the rename and cover both cases?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I’ll trace the rename hooks and make sure existing slices keep their permissions in sync after a semantic-view rename.

Comment thread superset/models/dashboard.py Outdated
datasource = next(iter(slices)).datasource

if datasource:
if isinstance(datasource, BaseDatasource):

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.

Grouping these slices by bare datasource_id merges the independent SqlaTable and SemanticView ID spaces. If both have ID 5, next(iter(slices)) can select the semantic-view chart and this guard drops the entire group, including the table metadata, or it can pass the semantic slice into the table's data_for_slices; can this key by (datasource_type, datasource_id) and cover a mixed dashboard collision?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I’ll change the grouping to include the datasource type and add coverage for table/semantic-view ID collisions.

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

Thanks for taking this on @Kunal8954, and for keeping the command guard an explicit allowlist. I verified the core fix in a running environment on this branch: POST /api/v1/chart/ with datasource_type="semantic_view" against a real SemanticView row returns 201, set_related_perm syncs the chart's perm to the view's perm, a user without the view's datasource_access perm cannot list the chart, and a user holding it can list and open it. The same guard on the parent commit rejects the request, so the fix does what it says.

I still have to request changes, because the current head cannot pass CI:

  • The new Slice.semantic_view relationship breaks deletion retention. On this branch tests/unit_tests/commands/deletion_retention/ has 14 failures, all RuntimeError: Incomplete purge policy for Slice: missing=[relationship:slices->semantic_views:->:manytoone:semantic_view]; the same suite passes on the parent commit. Since get_purge_policy(Slice) raises, chart purging itself breaks, not just the tests. This is the failure @sadpandajoe predicted on the relationship thread. Note CI has not run on a5d5b0b, so the earlier green Python-Unit run on d159207 does not cover this.
  • test_create_chart_from_semantic_view fails as written in a real environment; details inline, including the fix I verified.
  • The chart filter gained a datasource_type guard, but DashboardAccessFilter still has the identical unguarded join; details inline.

The direction is right and the remaining work looks mechanical. Happy to dig in with you on any of these.


# Without the view's datasource_access perm, a non-owner cannot
# list/open the chart.
with self.temporary_user(gamma, login=True):

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.

This test cannot pass as written. I ran it in a real environment (sqlite metadata DB plus Redis) and it fails here with 1 == 0, for two independent reasons:

  • self.login(ADMIN_USERNAME) above leaves an authenticated session, and FAB's AuthDBView.login redirects an already authenticated session without re-authenticating (the g.user.is_authenticated early return in flask_appbuilder/security/views.py). So every temporary_user(..., login=True) block here still runs as admin, and admin sees the chart. Adding self.logout() before the first block fixes this; I verified it on this branch.
  • The all_database_access block then still fails, because ChartFilter.apply returns the unfiltered query when security_manager.can_access_all_datasources() is true, and that helper includes all_database_access. The short circuit happens before any join, so this assertion does not exercise the id ride-along protection the comment describes, and the expectation contradicts SemanticView.raise_for_access, which also grants on can_access_all_datasources(). To pin the ride-along protection, grant access to one specific database and create a table whose id collides with the view id, then assert the chart stays hidden.

With self.logout() added and that block corrected, the rest passes for me on this branch: 201 on create, perm synced, hidden without the view perm, visible with it.

Comment thread superset/charts/filters.py Outdated
table_alias,
and_(
Slice.datasource_id == table_alias.id,
Slice.datasource_type == DatasourceType.TABLE,

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.

The guard here is right, but its sibling is still unguarded: DashboardAccessFilter._apply_viewers in superset/dashboards/filters.py has the identical join, .join(SqlaTable, Slice.datasource_id == SqlaTable.id), with no datasource_type condition. Once semantic view charts land on dashboards, a published no-viewer dashboard whose semantic view chart collides with an accessible SqlaTable.id becomes listable through that join, and conversely a dashboard containing only semantic view charts can never match the fallback even for users who hold the view perm, because the joined rows do not exist and get_dataset_access_filters(Slice) never gets to check Slice.perm. I would apply the same datasource_type == DatasourceType.TABLE guard there and add a semantic view arm mirroring this one, in this PR, since this PR is what makes such charts reachable.

Comment thread superset/charts/filters.py Outdated
and_(
Slice.datasource_type == DatasourceType.SEMANTIC_VIEW,
~chart_has_viewers,
Slice.perm.in_(

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, a consistency question: SemanticView.raise_for_access also grants when the user holds datasource_access on the parent layer's perm, but both this branch and the chart access path (can_access_datasource, which checks only datasource.perm) look at the view perm alone. A user granted at the layer level can explore the view but cannot open or list a chart saved on it. Everything fails closed, so no security concern, but is the asymmetry intended?

…emantic-view-chart-save

# Conflicts:
#	superset/models/slice.py
#	tests/unit_tests/models/slice_test.py
@bito-code-review

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

Copy link
Copy Markdown
Contributor

Code Review Agent Run #5f9766

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: a5d5b0b..3672656
    • superset/security/manager.py
    • tests/unit_tests/semantic_layers/models_test.py
    • tests/unit_tests/subjects/test_raise_for_access.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

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

Thanks for the quick turnaround @Kunal8954, and good news first: two of my three blockers are gone. superset/models/slice.py dropped out of this PR in the master merge, so that relationship is upstream's now. On the merge result (refs/pull/44169/merge, eea15d7) I re-ran the suites:

  • tests/unit_tests/commands/deletion_retention/: 98 passed. master declares the missing entry itself at superset/commands/deletion_retention/purge_policy.py:557, so the purge policy concern is closed.
  • DashboardAccessFilter._apply_viewers is type guarded upstream at superset/dashboards/filters.py:194 with a SemanticView arm, so that one is closed too.
  • tests/unit_tests/charts/test_filters.py, tests/unit_tests/subjects/test_raise_for_access.py, tests/unit_tests/semantic_layers/models_test.py plus deletion retention together: 226 passed.

I also checked your new command tests are genuine regression tests: reverting the guard in create.py and update.py to TABLE only fails both of them.

Two blockers left.

test_update_chart_accepts_semantic_view_datasource fails on the merge result

Not your doing. The master merge added raise_if_managed_externally(self._model, ChartForbiddenError) right after the editorship check in UpdateChartCommand.validate, so the bare MagicMock at line 293 makes is_managed_externally truthy and validate() raises ChartForbiddenError before it ever reaches the datasource guard the test is about. After the merge, every other find_by_id mock in that file sets is_managed_externally=False. One line, inline below. I verified it: 1 failed, 69 passed before, 70 passed after.

test_create_chart_from_semantic_view is unchanged, and CI now confirms it

test-sqlite, test-postgres and test-mysql on 3672656 all fail at tests/integration_tests/charts/api_tests.py:778 with assert 1 == 0, which is the first temporary_user(gamma, login=True) block, the self.logout() problem. The all_database_access block right after it still needs the rewrite too: ChartFilter.apply returns the query unfiltered when can_access_all_datasources() is true (superset/charts/filters.py:120), and that helper covers all_database_access through can_access_all_databases() (superset/security/manager.py:2211 and :2221). Full detail is on the existing thread.

Two non-blockers:

  • The layer grant question from last time is now the odd one out. master has since aligned three siblings on it: _semantic_layer_grant_allows (superset/security/manager.py:2286, used by the datasource branch at :4838) and layer_grant_clause (superset/dashboards/filters.py:175), whose comment explicitly anticipates the chart list mirror of that clause. Your arm at superset/charts/filters.py:183 matches Slice.perm alone. I verified the effect on this branch: holding only the layer perm, can_access_datasource(view) is True but the chart is absent from ChartFilter._apply_viewers. It fails closed, so nothing unsafe, just a chart that opens but never lists.
  • datasets_trimmed_for_slices still groups by bare datasource_id (superset/models/dashboard.py:353), which is @sadpandajoe's point. The isinstance change stops the crash but not the collision. I created a SqlaTable and a SemanticView that both got id=1, put a chart from each on one dashboard, and datasets_trimmed_for_slices() returned zero datasources in 3 of 5 runs: next(iter(slices)) picked the semantic view slice, whose Slice.datasource is None, and the table chart's own payload went with it. Keying by (datasource_type, datasource_id) covers both halves.

Happy to dig into either non-blocker with you.

Co-authored-by: Gabriel Torres Ruiz <[email protected]>
@mikebridge

Copy link
Copy Markdown
Member

@Kunal8954 — routing a concrete dashboard regression from SC-120295 / preset-io/superset-shell#5140 to the existing SC-120289 host work. This extends the dashboard metadata concern in #44169 (comment); it is separate from MCP dashboard serialization #44269.

On core 2db9d6d51c8623810a2dba5b796c5154147d7d76, an isolated dashboard with semantic-view Table, BigNumber and monthly charts renders valid numeric results. With malformed, NaN or overflowing numeric input, all three chart requests correctly return HTTP 400 with a bounded metric/category message, and frontend Redux reaches failed with that message. The visible dashboard nevertheless shows loading indicators: /api/v1/dashboard/1/datasets returns {"result":[]}, so it retains PLACEHOLDER_DATASOURCE, and components/Chart/Chart.tsx suppresses message-only errors in that state.

Source inspection at your current ff4829b8308c49e92942df3f53c510238c87525c still shows the relevant path: Dashboard.datasets_trimmed_for_slices reads next(iter(slices)).datasource, while Slice.datasource returns only self.table; the placeholder guard is also present. This is source confirmation at your head, not a browser rerun of your branch. No changes made to your branch.

Suggested regression coverage: a semantic-only dashboard must supply its authorized datasource metadata; a mixed table/semantic dashboard with colliding integer IDs must keep both identities distinct; a semantic query HTTP400 must produce a visible terminal error rather than a spinner. Preserve the existing access checks/type boundaries. Numeric's valid rendering is verified with mocked remote GraphQL/Arrow and real provider/host/frontend; its visible-error gate remains open pending the host fix. Local reproducible scripts, screenshots, response bodies and Redux evidence are saved under superset-spec/specs/sc-120295-metricflow-numeric-contract/validation/browser-foundation-20260916/ (no live-provider or production claim).

temporary_user(login=True) cannot replace an already-authenticated
session, so the gamma checks ran as admin and saw the chart. Log out
first, and align the all_database_access expectation with the existing
can_access_all_datasources short-circuit (count 1, not 0).
@bito-code-review

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

Copy link
Copy Markdown
Contributor

Code Review Agent Run #29b394

Actionable Suggestions - 0
Additional Suggestions - 2
  • tests/unit_tests/semantic_layers/models_test.py - 1
    • Duplicate test logic · Line 1501-1608
      These two new tests (1501-1555, 1558-1608) are structurally identical, differing only in UUID, names, the granted perm, and the final assertion. Consider consolidating into one parametrized test (e.g. `pytest.mark.parametrize` over the granted perm and expected visibility) to avoid divergence when the filter logic changes.
  • tests/unit_tests/commands/chart/update_test.py - 1
    • Unused mock attribute · Line 293-295
      `is_managed_externally` is only read on dashboard objects in `update.py` (line 129: `dash.is_managed_externally`), never on the chart model returned by `ChartDAO.find_by_id`. This attribute on the chart mock is not exercised by the tested `_validate_query_context_datasource` path, so it adds no coverage and may mislead readers.
Review Details
  • Files reviewed - 5 · Commit Range: 3672656..79c0cff
    • tests/unit_tests/commands/chart/update_test.py
    • superset/charts/filters.py
    • tests/unit_tests/charts/test_filters.py
    • tests/unit_tests/semantic_layers/models_test.py
    • tests/integration_tests/charts/api_tests.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

…ources by type

datasets_trimmed_for_slices: group by (datasource_type, datasource_id) so a semantic-view chart and a table chart sharing an auto-increment id (e.g. both id=5) don't collapse into one group and drop the table's datasource from the validation set.

semantic_layer_before_update / semantic_view_before_update: after a layer or view rename, propagate the new perm to dependent semantic-view charts so chart-list access filters (which match on Slice.perm) stay in sync.

Adds regression coverage for the id collision in dashboard_test.py and for the layer-rename chart-perm cascade in semantic_layers/models_test.py.
@Kunal8954

Kunal8954 commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Hey — could you re-run the failed cypress-matrix job when you get a chance? It died on a fetch failed in the setup-uv step before any tests ran, so it looks like a transient infra hiccup rather than something from this PR. Everything else on this head is green.

@github-actions github-actions Bot added i18n Namespace | Anything related to localization i18n:spanish Translation related to Spanish language i18n:italian Translation related to Italian language i18n:french Translation related to French language i18n:chinese Translation related to Chinese language i18n:japanese Translation related to Japanese language i18n:russian Translation related to Russian language i18n:korean Translation related to Korean language i18n:dutch i18n:slovak i18n:ukrainian i18n:portuguese i18n:brazilian i18n:traditional-chinese labels Sep 23, 2026
@bito-code-review

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

Copy link
Copy Markdown
Contributor

Code Review Agent Run #f84dcf

Actionable Suggestions - 0
Additional Suggestions - 2
  • superset/translations/ko/LC_MESSAGES/messages.po - 1
    • Missing Korean translation · Line 25419-25422
      The msgid was updated to match the new source string in `exceptions.py` (adding OAuth2 endpoint URIs / client secret), but the `msgstr` at line 25423 is empty. Korean users will see the untranslated English text for this connection-move confirmation. Add the Korean translation for the changed message.
  • superset/translations/zh_TW/LC_MESSAGES/messages.po - 1
    • Missing zh_TW translation · Line 18529-18532
      The msgid was updated to match the new source string in `superset/commands/database/exceptions.py` (OAuth2 endpoint URIs / client secret), but the `msgstr` at line 18533 is empty, so zh_TW users will see the English fallback for this connection-move error. Add the zh_TW translation.
Review Details
  • Files reviewed - 31 · Commit Range: 12300a8..e766334
    • superset/translations/ar/LC_MESSAGES/messages.po
    • superset/translations/ca/LC_MESSAGES/messages.po
    • superset/translations/cs/LC_MESSAGES/messages.po
    • superset/translations/de/LC_MESSAGES/messages.po
    • superset/translations/en/LC_MESSAGES/messages.po
    • superset/translations/es/LC_MESSAGES/messages.po
    • superset/translations/fa/LC_MESSAGES/messages.po
    • superset/translations/fi/LC_MESSAGES/messages.po
    • superset/translations/fr/LC_MESSAGES/messages.po
    • superset/translations/it/LC_MESSAGES/messages.po
    • superset/translations/ja/LC_MESSAGES/messages.po
    • superset/translations/ko/LC_MESSAGES/messages.po
    • superset/translations/lv/LC_MESSAGES/messages.po
    • superset/translations/messages.pot
    • superset/translations/mi/LC_MESSAGES/messages.po
    • superset/translations/nl/LC_MESSAGES/messages.po
    • superset/translations/pl/LC_MESSAGES/messages.po
    • superset/translations/pt/LC_MESSAGES/messages.po
    • superset/translations/pt_BR/LC_MESSAGES/messages.po
    • superset/translations/ro/LC_MESSAGES/messages.po
    • superset/translations/ru/LC_MESSAGES/messages.po
    • superset/translations/sk/LC_MESSAGES/messages.po
    • superset/translations/sl/LC_MESSAGES/messages.po
    • superset/translations/sr/LC_MESSAGES/messages.po
    • superset/translations/sr_Latn/LC_MESSAGES/messages.po
    • superset/translations/ta/LC_MESSAGES/messages.po
    • superset/translations/th/LC_MESSAGES/messages.po
    • superset/translations/tr/LC_MESSAGES/messages.po
    • superset/translations/uk/LC_MESSAGES/messages.po
    • superset/translations/zh/LC_MESSAGES/messages.po
    • superset/translations/zh_TW/LC_MESSAGES/messages.po
  • Files skipped - 0
  • Tools
    • 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

…emantic-view-chart-save

# Conflicts:
#	superset/translations/ar/LC_MESSAGES/messages.po
#	superset/translations/ca/LC_MESSAGES/messages.po
#	superset/translations/cs/LC_MESSAGES/messages.po
#	superset/translations/de/LC_MESSAGES/messages.po
#	superset/translations/en/LC_MESSAGES/messages.po
#	superset/translations/es/LC_MESSAGES/messages.po
#	superset/translations/fa/LC_MESSAGES/messages.po
#	superset/translations/fi/LC_MESSAGES/messages.po
#	superset/translations/fr/LC_MESSAGES/messages.po
#	superset/translations/it/LC_MESSAGES/messages.po
#	superset/translations/ja/LC_MESSAGES/messages.po
#	superset/translations/ko/LC_MESSAGES/messages.po
#	superset/translations/lv/LC_MESSAGES/messages.po
#	superset/translations/messages.pot
#	superset/translations/mi/LC_MESSAGES/messages.po
#	superset/translations/nl/LC_MESSAGES/messages.po
#	superset/translations/pl/LC_MESSAGES/messages.po
#	superset/translations/pt/LC_MESSAGES/messages.po
#	superset/translations/pt_BR/LC_MESSAGES/messages.po
#	superset/translations/ro/LC_MESSAGES/messages.po
#	superset/translations/ru/LC_MESSAGES/messages.po
#	superset/translations/sk/LC_MESSAGES/messages.po
#	superset/translations/sl/LC_MESSAGES/messages.po
#	superset/translations/sr/LC_MESSAGES/messages.po
#	superset/translations/sr_Latn/LC_MESSAGES/messages.po
#	superset/translations/ta/LC_MESSAGES/messages.po
#	superset/translations/th/LC_MESSAGES/messages.po
#	superset/translations/tr/LC_MESSAGES/messages.po
#	superset/translations/uk/LC_MESSAGES/messages.po
#	superset/translations/zh/LC_MESSAGES/messages.po
#	superset/translations/zh_TW/LC_MESSAGES/messages.po

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

Delta since 12300a84 is three master merges plus a translations regeneration, nothing else: superset/models/dashboard.py and superset/security/manager.py are byte for byte what I approved, so the substance here is still the two rename cascades at superset/security/manager.py:4256 and :4376 plus the tests.

Verified by running rather than reading: tests/unit_tests/dashboards/datasets_test.py is 13 passed on the head (411340c8) and on the merge ref (949e630a), so the #44413 resolution held through all three merges, and test_datasets_trimmed_for_slices_keeps_colliding_ids_separate still passes in its adapted form. 1252 passed across the affected suites plus the new permission migration tests. Renaming a layer and renaming a view each still keep Slice.perm in sync.

Since #44142 landed overnight and both it and your cascades write permission rows, I checked for a collision and there is none. Its delete migration targets an explicit ten entry PVM_LIST of ("Superset", "can_*") pairs, and the rename migration's PVM_MAP is keyed on OLD_VIEW_MENU = "Superset", so neither names a datasource_access view menu, which that migration calls out as deliberate. Your cascades only touch datasource_access view menus and the two denormalized perm columns.

The messages.pot conflict is gone too: nothing under superset/translations differs from master now, and the PR is back to ten files.

@rusackas

Copy link
Copy Markdown
Member

Follow-up, please. Looking again I was behind on that last pass, sorry: gabotorresruiz had already confirmed the purge policy entry and the dashboards/filters.py guard are on master, and slice.py isn't in this diff anymore, so the leftover bare-id comparisons belong in their own PR. Thanks for sticking with this one.

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

LGTM, thanks for sticking with this one through all the rounds @Kunal8954. Re-checked the remaining diff myself and the two open threads sadpandajoe/gabotorresruiz raised are both closed on master now, not just addressed in this PR. Merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

requires:rebase Requires rebasing on top of current master size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to save slice for table created from Semantic View source

5 participants