Repository navigation
fix(charts): allow saving charts on semantic views (create/update rejected non-table datasource types) - #44416
Conversation
Keep SQL Lab query sources rejected while authorizing persistent semantic views through the manager policy. Validate retained datasource IDs on type-only updates and map POST access denial to 403. Fold independent review coverage and nullable-ID findings for SC-121388.
Code Review Agent Run #035c86Actionable 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 |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
The flagged issue is correct. In the original code, if I have reviewed the changes in Regarding other comments on this PR: I have checked the provided files and there are no other review comments in the superset/commands/chart/update.py |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #44416 +/- ##
=======================================
Coverage 80.56% 80.57%
=======================================
Files 2938 2940 +2
Lines 175246 175315 +69
Branches 40680 40689 +9
=======================================
+ Hits 141184 141257 +73
+ Misses 31396 31395 -1
+ Partials 2666 2663 -3
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:
|
Distinguish an omitted datasource_id from explicit null so the validation guard runs instead of authorizing the stored source while persisting null. Cover table and semantic-view cases; addresses CodeAnt thread 4044282752.
richardfogaca
left a comment
There was a problem hiding this comment.
Richard's agent here:
Reviewed 5d3bf53ad2. The authorization shape is right and I found nothing that grants access it should not. Approving, with one finding I would like fixed here or in an immediate follow-up because it affects the denial path this PR opens up.
Important: a real semantic-view denial does a provider round-trip while building the 403. create.py, update.py, and explore/utils.py all end in security_manager.raise_for_access(datasource=<SemanticView>). On denial, get_datasource_access_error_object and get_datasource_access_link in security/manager.py both read datasource.data["id"], and SemanticView.data calls implementation.get_metrics() / _unique_dimensions, which instantiates the provider from the layer configuration. So a Gamma user without access to view 42 posting datasource_type=semantic_view, datasource_id=42 makes Superset call Cube/Snowflake before it can say 403. If the provider is unreachable, credentials rotated, or the layer type is not registered, the raised exception is not a security exception, so validate() lets it escape and @transaction turns it into a 422 "Fatal error" (500 on the form_data path, where only SupersetSecurityException is swallowed). This is pre-existing in the manager, not introduced here, and it is fail-closed, but the PR body's "denial returns the documented 403" only holds when the provider answers, and the unit fixture had to patch SemanticView.data for exactly this reason. Small suggestion: use datasource.id in those two manager call sites (the value is the same for tables), and add a Gamma denial test with the provider mocked to raise, so the 403 is pinned without a provider.
Observations, non-blocking:
- The
SEMANTIC_LAYERSflag is not consulted on save:validate_chart_datasource_typeacceptssemantic_viewregardless, while the datasource API 404s when the flag is off. Only reachable for rows created while the flag was on. Could we gate the same way, or note the asymmetry? - The body says PUT binds query-context type/id; at head only the query-context-only update path checks that, so a full PUT with a
query_contextpointing at a different{id, type}is not validated. Pre-existing and unchanged, just worth not over-claiming. - The negative tests inject denial via a mocked
raise_for_access; no test drives real Gamma perm evaluation. The body already lists that as a follow-up.
Verified with no issues: lookups are namespace-exact in both directions (a view id with type=table resolves a table or 422s, never a view); the type-only update path re-resolves the retained id in the requested namespace and re-checks access; datasource_id: null 422s before lookup; the form_data branch cannot reach the dashboard/guest legs because saves pass only datasource=; set_related_perm lands Slice.perm = view.perm so the type-aware chart-list filter from #43848 admits layer grants; the new *_tests.py module is collected by the integration jobs; the docs paragraph matches the code. CI is green on this head.
There was a problem hiding this comment.
Code Review Agent Run #d12fb6
Actionable Suggestions - 1
-
superset/commands/chart/update.py - 1
- Incomplete null datasource guard · Line 215-215
Review Details
-
Files reviewed - 2 · Commit Range:
1388429..5d3bf53- superset/commands/chart/update.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
| # A type-only change still selects a different datasource namespace. | ||
| effective_id: int | None = ( | ||
| datasource_id | ||
| if "datasource_id" in self._properties |
There was a problem hiding this comment.
The null-datasource_id rejection only fires inside if datasource_type: (line 209). When a client sends datasource_id: null without datasource_type, that block is skipped, no error is raised, and run() persists the null via ChartDAO.update (base.py:548), wiping the chart's datasource binding. The hardening added here is incomplete for the no-type case.
Code Review Run #d12fb6
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
|
@richardfogaca @aminghadersohi — immediate follow-up opened: #44432, addressing Richard's September 18, 18:21 UTC review. 0eb74a1490 reads the persisted datasource id in both denial builders. Real Gamma chart create/update and Explore form_data regressions now return 403 without touching the failing provider. Validation: 113 HTTP tests, 262 unit tests, required hooks, and independent review with zero findings. The follow-up body explicitly defers the flag-off save asymmetry and states that query-context type/id binding is checked on create and query-context-only update, not full PUT. Please review #44432; GitHub denied this account's formal reviewer-request permission. |
SUMMARY
Fixes the semantic-view chart-save regression tracked in SC-121388.
#43500 correctly rejected SQL Lab query objects, but its TABLE-only guard also rejected persistent semantic views. #43781 provides type-aware
Slice.resolved_datasourceresolution. This change allows only TABLE and SEMANTIC_VIEW, retaining thequery/saved_queryrejection.The Cube member-identity walkthrough stopped at step 4: Save as sent
datasource_type: "semantic_view"and received HTTP 422, "Datasource type is invalid". Create and overwrite can now resolve the semantic view, populate its name, and enforce datasource access.Independent Claude review confirmed namespace-exact lookup, manager-based grants, query-context type/id binding, and denial on both POST and PUT. The review's policy-consistency and type-only coverage findings have been folded in:
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Backend change; no UI layout change. Before: semantic-view Save as/overwrite returns 422. After: allowed saves return 201/200 and persist the semantic-view identity. Browser save/reopen on the integrated provider stack remains to be re-exercised after the core fix is consumed.
Unblocks #44370. Its browser walkthrough (save as → reopen a Cube semantic-view chart) passes only with this change applied; on master the save returns 422. The two should land in that order, or together.
TESTING INSTRUCTIONS
semantic_view, including after reopening.queryandsaved_querycreate requests still return 422.Local verification on the final tree:
Follow-ups (not claimed covered): align the shared
get_datasource_by_idreturn annotation/consumers with SemanticView; add a real Gamma view/parent-layer grant HTTP case with provider-backed metadata and permission cleanup. Existing HTTP positives use admin and denial injection tests the route's error translation. No live-provider/browser validation or PostgreSQL/MySQL run is claimed here.ADDITIONAL INFORMATION
SEMANTIC_LAYERS.Codex authored; Claude independently reviewed. Human review remains required.