Skip to content

fix(api): enforce is_managed_externally on chart/dashboard/dataset update - #44025

Merged
richardfogaca merged 10 commits into
apache:masterfrom
mikebridge:sc-120011-update-managed-externally-gate
Sep 15, 2026
Merged

richardfogaca merged 10 commits into
apache:masterfrom
mikebridge:sc-120011-update-managed-externally-gate

Conversation

@mikebridge

@mikebridge mikebridge commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

SUMMARY

An entity with is_managed_externally = True has its source of truth outside Superset: an in-app write would be overwritten on the next external sync, which is why the UI hides the edit affordances for such entities. But the refusal was browser-only — an otherwise-authorized editor could still mutate the entity by calling PUT /api/v1/{chart,dashboard,dataset}/<id> directly. This is the ordinary-update counterpart of the gap #44013 closes for version restore (in review), and landing both keeps the restore and update surfaces from drifting.

Core change: a shared raise_if_managed_externally helper in superset/commands/utils.py, called from all three UpdateCommand.validate() implementations after the editorship check, raising each entity's existing editorship-denial exception (ChartForbiddenError / DashboardForbiddenError / DatasetForbiddenError) so the HTTP 403 body is identical to a permission denial and discloses nothing new.

Hardening from the adversarial review round (initially-proposed exemptions turned out to be bypasses):

  • Chart query-context-only saves are gated too. Stored query_context is executable state — report execution loads and runs it — so a client-supplied context on a managed chart changes chart/report behavior; it is not derived state. No server-side path writes it: Explore's background context save is the only writer, and for a managed chart that fire-and-forget call receives a 403 it ignores.
  • The dashboard colors-sync exemption is narrowed to derived values. PUT /api/v1/dashboard/<id>/colors fires in the background whenever an editor merely views a dashboard with stale color metadata, so it stays writable on managed dashboards — but only for the derived keys (color_scheme_domain, shared_label_colors, map_label_colors). A payload that would change the authoritative color_scheme/label_colors (persisted into exported json_metadata) is refused with the same 403. The colors command also dispatches through its own validate() override (its run() previously called the parent's validate directly).
  • PUT /api/v1/dataset/<pk>/refresh is gated after editorship: refresh persists fetched column metadata, which the external sync owns.
  • The ordinary PUT schemas discard is_managed_externally on load. The field was client-writable, and with the gate in place a client-set true would have been irreversible via the API (the stored flag is checked before any payload is applied). The field stays declared (preserving the published OpenAPI contract and generated clients) but a @pre_load hook drops the key before field loading, so it can never reach the loaded payload — and clients echoing GET payloads back on PUT don't start failing on an unknown field.
  • The legacy Explore overwrite is gated too. /superset/explore/ with action=overwrite assigns request values (params, query_context, …) directly to the loaded chart and persists via ChartDAO.update, bypassing the command layer — refused after the editorship check with the same 403 message, pinned by a regression test that asserts the refusal message (a 403 from an unrelated check cannot satisfy it). En route this fixed a latent pre-existing bug: the overwrite editorship denial directly above passed a flask-babel LazyString to json_error_response (whose isinstance(str) check it fails), so that 403 has been shipping an empty {} body — both denials now use the eager gettext alias and carry their message.

Scope note: this is a data-integrity consistency fix, not a privilege escalation — an editor holding edit rights is entitled to mutate these entities under the role/capability matrix; is_managed_externally is an external-sync integrity concern. Direct DAO/model write surfaces that bypass the command layer (MCP tools, legacy Explore overwrite) are inventoried in a separate follow-up.

There is precedent for the check in this very layer: UpdateChartCommand already refuses linking a chart to an externally managed target dashboard.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — API-only behavior change. Before: PUT on an externally managed entity returned 200 and mutated it. After: HTTP 403, entity unchanged.

TESTING INSTRUCTIONS

  • pytest tests/unit_tests/commands/test_update_managed_externally.py — 15 tests: parametrized refusal across chart/dashboard/dataset (the single raise_for_editorship call also pins that the gate runs after editorship); call-site wiring pins; the chart query-context-only refusal; colors derived-only exemption + parametrized authoritative-key refusals; the dataset refresh gate; the PUT schemas discarding the flag (no field, no 422, key absent after load); the helper contract. Reverting only the production changes flips 7 of the 15 (verified via stash control).
  • tests/integration_tests/charts/api_tests.py::TestChartApi::test_update_chart_refuses_externally_managed — representative real-endpoint case: admin PUT on an externally managed chart returns 403 and the chart is unchanged (exception-safe cleanup).
  • tests/integration_tests/core_tests.py::TestCore::test_overwrite_refuses_externally_managed_slice — the legacy Explore overwrite path: action=overwrite on a managed chart returns 403 with the refusal message and the chart (including query_context) is unchanged.
  • Manual: flip is_managed_externally on any chart, then PUT /api/v1/chart/<id> with {"slice_name": "x"} as an admin → 403; flip it back → 200. On a managed dashboard, PUT /api/v1/dashboard/<id>/colors with a changed color_scheme → 403; with only derived keys → 200.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

🤖 Generated with Claude Code

https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW

@codecov

codecov Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.61905% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.25%. Comparing base (4c27cbd) to head (c2d7b55).

Files with missing lines Patch % Lines
superset/utils/schema.py 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #44025   +/-   ##
=======================================
  Coverage   80.25%   80.25%           
=======================================
  Files        2927     2927           
  Lines      173166   173198   +32     
  Branches    40156    40161    +5     
=======================================
+ Hits       138973   139001   +28     
- Misses      31600    31603    +3     
- Partials     2593     2594    +1     
Flag Coverage Δ
hive 37.36% <45.23%> (-0.01%) ⬇️
mysql 56.91% <78.57%> (+<0.01%) ⬆️
postgres 56.94% <78.57%> (+<0.01%) ⬆️
presto 39.45% <45.23%> (-0.01%) ⬇️
python 84.68% <97.61%> (-0.01%) ⬇️
sqlite 56.63% <78.57%> (+<0.01%) ⬆️
unit 76.18% <90.47%> (+<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.

@mikebridge
mikebridge force-pushed the sc-120011-update-managed-externally-gate branch 3 times, most recently from 51fa53a to 3c37f08 Compare September 8, 2026 21:54
@netlify

netlify Bot commented Sep 8, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 294ae15
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6aa083a54a529800081a70ff
😎 Deploy Preview https://deploy-preview-44025--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.

@netlify

netlify Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit c2d7b55
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6aa9b0eb3e8b3f00088ece5a
😎 Deploy Preview https://deploy-preview-44025--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.

@pull-request-size pull-request-size Bot added size/XL and removed size/L labels Sep 8, 2026
@github-actions github-actions Bot added api Related to the REST API requires:rebase Requires rebasing on top of current master labels Sep 8, 2026
@mikebridge
mikebridge marked this pull request as ready for review September 9, 2026 16:26
@mikebridge

Copy link
Copy Markdown
Member Author

@aminghadersohi — requesting review on the is_managed_externally server-side gate (sc-120011), the update-path counterpart of the restore gate in #44013. Data-integrity fix, not privilege escalation: an otherwise-authorized editor could mutate an externally managed chart/dashboard/dataset via direct PUT (the UI only hides the affordances), and the change would be overwritten on the next external sync.

Shape: one shared raise_if_managed_externally helper called after the editorship check in all three UpdateCommand.validate()s, raising each entity's existing 403 exception so the refusal is indistinguishable from a permission denial. The PR went through two adversarial review rounds beyond my own lens gate, which hardened it well past the original scope — worth knowing as you review:

  • both initially-proposed "derived state" exemptions turned out to be live integrity holes and were closed: the chart query-context-only save is gated (stored query context is executable — report execution runs it; nothing server-side writes it, so report machinery is unaffected), and the dashboard colors sync is narrowed to derived values (color_scheme/label_colors refused when changed on a managed dashboard; the background view-time sync keeps flowing);
  • PUT /dataset/<pk>/refresh is gated (fetch_metadata persists column metadata the external sync owns);
  • the legacy Explore overwrite (/superset/explore/, action=overwrite) is gated — it writes query_context via ChartDAO.update, bypassing the command layer. En route this fixed a latent pre-existing bug: that path's editorship denial passed a flask-babel LazyString to json_error_response and has been shipping empty {} 403 bodies (both denials now eager-translate);
  • the PUT schemas discard is_managed_externally on load (declared for the OpenAPI contract, popped in pre_load) — it was client-writable, and a client-set true would have been irreversible once the gate exists.

Remaining direct DAO writers (MCP tools, certification paths) are inventoried in a follow-up ticket rather than folded in. Tests: 15 unit (parametrized across the three entities; reverting the production change flips 7) + 2 integration (REST PUT 403 + legacy overwrite 403, both asserting the body). CI fully green at cf2f4cb including the DB matrix, unit lane, and openapi-spec-drift (the two commits after f7d40c0 are test-only: mock-fixture flag pins and a docstring nit).

🤖 Generated with Claude Code

https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW

mikebridge added a commit to mikebridge/superset that referenced this pull request Sep 9, 2026
- The comment and test docstring cited UpdateDashboardCommand's
  raise_if_managed_externally gate as existing shared code; that gate is
  proposed in the open apache#44025 — reworded intent-shaped
  (the in-tree dashboard command layer has no managed-externally check
  at all, which makes the tool-local refusal MORE necessary, not less).
- The gate now sits below the no-field inspect branch: reading current
  certification values changes nothing and stays available on managed
  dashboards (they are readable via get_dashboard_info anyway), pinned
  by a new test.
- DashboardMutationErrorFields.permission_denied description widened to
  cover object-state refusals, so agents don't steer users toward
  requesting edit rights that would not help.

sc-120051

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
mikebridge added a commit to mikebridge/superset that referenced this pull request Sep 9, 2026
Cross-model round folds: the denial test is parametrized across BOTH
badge fields and both set and clear (gating one field but not the other
can no longer pass), the inspect test pins certification_details
preservation and changed_fields == [], the apache#44025 references are
replaced with the durable invariant (direct assign+commit means no
command-layer check can protect this tool), and the added result locals
are annotated CallToolResult.

sc-120051

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
@bito-code-review

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

Copy link
Copy Markdown
Contributor

Code Review Agent Run #d09bae

Actionable Suggestions - 0
Additional Suggestions - 4
  • superset/commands/dashboard/update.py - 2
    • False-positive authoritative change · Line 330-330
      `_changes_authoritative_colors` compares `self._properties[key] != metadata.get(key)`. The frontend `storeDashboardColorConfig` always sends `label_colors: metadata.label_colors || {}`, so when the stored `label_colors` is absent (None) the server sees `{} != None` → True and raises `DashboardForbiddenError`, blocking the very background sync this PR is meant to allow. Consider treating an empty incoming value as unchanged when the stored value is absent.
    • Editorship enforced on sync · Line 338-338
      `run()` now calls `self.validate()`, which invokes `raise_for_editorship` (base `validate()` line 126). The PR comment states the colors sync should keep working "while a dashboard is merely viewed". If `persistDashboardLabelsColor`/`ensureSyncedLabelsColorMap` fire for non-editor viewers, this new call will 403 the sync. Verify the frontend gates the sync by edit permission, or the sync will silently fail for viewers.
  • tests/integration_tests/core_tests.py - 1
    • Trivial query_context assertion · Line 244-244
      The `Energy Sankey` slice from the `load_energy_table_with_slice` fixture has no `query_context` (only the Heatmap slice in `energy_dashboard.py` sets one), so `original_query_context` is `None` and line 244 asserts `None == None` — trivially true regardless of the gate. Set a non-None `query_context` on the slice before the overwrite so the assertion actually verifies preservation.
  • superset/commands/chart/update.py - 1
    • Misleading comment on client behavior · Line 221-223
      The comment says the background Explore save "gets a 403 it ignores," but `updateQueryContext` in `ExploreChartPanel/index.tsx` awaits `SupersetClient.put` with no try/catch or `.catch()`, and no global `unhandledrejection` handler exists. A 403 here yields an unhandled promise rejection, not a silently-ignored error. Consider rewording to avoid misleading future maintainers.
Review Details
  • Files reviewed - 15 · Commit Range: a601c18..cf2f4cb
    • superset/charts/schemas.py
    • superset/commands/chart/update.py
    • superset/commands/dashboard/update.py
    • superset/commands/dataset/refresh.py
    • superset/commands/dataset/update.py
    • superset/commands/utils.py
    • superset/dashboards/schemas.py
    • superset/datasets/schemas.py
    • superset/views/core.py
    • tests/integration_tests/charts/api_tests.py
    • tests/integration_tests/core_tests.py
    • tests/unit_tests/commands/chart/update_test.py
    • tests/unit_tests/commands/dataset/refresh_test.py
    • tests/unit_tests/commands/dataset/update_test.py
    • tests/unit_tests/commands/test_update_managed_externally.py
  • Files skipped - 1
    • UPDATING.md - 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

mikebridge and others added 6 commits September 11, 2026 11:06
…date

An entity with is_managed_externally set has its source of truth outside
Superset; the browser hides the edit affordances, but the refusal was
browser-only — an otherwise-authorized editor could mutate the entity via
PUT /api/v1/{chart,dashboard,dataset}/<id> directly and have the change
overwritten on the next external sync. This is the update-path counterpart
of the matching gate apache#44013 adds to version restore.

Add a shared raise_if_managed_externally helper (commands/utils.py) and
call it from all three UpdateCommand.validate() implementations, after the
editorship check, raising each entity's editorship-denial exception so the
403 response body is identical to a permission denial and discloses
nothing new. Two derived-state save paths are deliberately exempt: the
chart query-context-only save (report workers) and the dashboard
colors-sync command (fired in the background while a dashboard is merely
viewed).

sc-120011

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
Rework from the adversarial review round: the two 'derived state'
exemptions were both live integrity holes, and two adjacent surfaces were
unguarded.

- The chart query-context-only save is now gated too: stored query
  context is executable state (report execution loads and runs it), so a
  client-supplied context on a managed chart is a behavior change, not
  derived state. No server-side path writes it (Explore's background save
  is the only writer and ignores the 403).
- The dashboard colors exemption is narrowed to derived values only:
  color_scheme and label_colors are authoritative content persisted into
  exported json_metadata, so a payload that would change them on a
  managed dashboard is refused; the derived keys (color_scheme_domain,
  shared_label_colors, map_label_colors) keep flowing so background
  colors sync still works. The colors command now dispatches through its
  own validate() override rather than calling the parent directly.
- PUT /api/v1/dataset/<pk>/refresh is gated after editorship: refresh
  persists fetched column metadata, which the external sync owns.
- The ordinary PUT schemas discard is_managed_externally on load: it was
  client-writable, and with the gate a client-set true would have been
  irreversible via the API. Discarded (pre_load) rather than removed so
  clients echoing GET payloads back do not start failing on an unknown
  field.

Direct DAO/model write surfaces that bypass the command layer (MCP tools,
legacy Explore overwrite) are tracked separately as a follow-up.

sc-120011

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
…ract

Committer re-run findings on the managed-externally gate:

- The legacy Explore save (/superset/explore/, action=overwrite) assigns
  request values (params, query_context, ...) directly to the loaded
  chart and persists via ChartDAO.update, bypassing UpdateChartCommand's
  gate — so an editor could still rewrite a managed chart's query
  context there. Refuse it after the editorship check with the same 403
  message, pinned by a regression test that asserts the refusal message
  (a 403 from an unrelated check cannot satisfy it). The remaining
  direct DAO writers are tracked separately.
- Removing is_managed_externally from the PUT schemas broke the
  published OpenAPI contract (spec-drift CI red). The field declarations
  are restored; the pre_load discard still runs first, so the key can
  never reach the loaded payload — declared for the contract, inert on
  load. Test updated to pin declared-but-discarded.
- Stale comment referencing the removed chart query-context exemption
  dropped; UPDATING.md covers the legacy-overwrite gate.

sc-120011

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
The new managed-externally gate (and the pre-existing editorship denial
directly above it, which shares the pattern) passed flask-babel's
lazy_gettext proxy to json_error_response, whose isinstance(str) check a
LazyString fails — so the 403 body degraded to {} and the regression
test's message assert failed on the CI Postgres/MySQL/SQLite lanes (the
only failure on both). Use the module's eager gettext alias so the denial
actually carries its message. Verified by a local probe with the
datasource check mocked: the body now reads
{"error": "You don't have the rights to alter this chart"}.

sc-120011

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
The new managed-externally gates read entity.is_managed_externally in
UpdateChartCommand / UpdateDatasetCommand / RefreshDatasetCommand
validate(); the pre-existing unit suites for those commands build their
entities as bare MagicMocks, whose auto-created attribute is truthy, so
35 tests started failing with the 403 refusal on the CI unit-tests lane.
Declare the flag False on the entity mocks — these tests model ordinary,
locally-managed entities. (The dashboard suite already passed: its
entity fixtures don't trip the gate.)

sc-120011

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
@mikebridge
mikebridge force-pushed the sc-120011-update-managed-externally-gate branch from cf2f4cb to 8a32575 Compare September 11, 2026 17:06
@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. In UpdateDashboardColorsConfigCommand, the logic key in self._properties and self._properties[key] != metadata.get(key) fails to detect a change when the new value is None (explicitly provided) and the key is missing from the existing metadata (where metadata.get(key) returns None).

To resolve this, you should check if the key is present in self._properties and compare the values directly, ensuring that None is treated as a distinct value from a missing key if necessary, or simply ensure the comparison handles the absence of the key correctly.

Here is a corrected version of _changes_authoritative_colors:

    def _changes_authoritative_colors(self) -> bool:
        assert self._model
        metadata = json.loads(self._model.json_metadata or "{}")
        for key in self._AUTHORITATIVE_COLOR_KEYS:
            if key in self._properties:
                # Check if the value is actually changing
                if self._properties[key] != metadata.get(key):
                    return True
        return False

I have validated this fix against the provided diff. Would you like me to check the other comments on this PR and implement fixes for them as well?

superset/commands/dashboard/update.py

def _changes_authoritative_colors(self) -> bool:
        assert self._model
        metadata = json.loads(self._model.json_metadata or "{}")
        for key in self._AUTHORITATIVE_COLOR_KEYS:
            if key in self._properties:
                # Check if the value is actually changing
                if self._properties[key] != metadata.get(key):
                    return True
        return False

…s absent

Bot finding on the colors gate, verified correct: an incoming
color_scheme/label_colors of null compared equal to metadata.get(key)'s
None default when the stored metadata lacked the key, slipping the
managed-externally refusal — yet the DAO writes every provided key, so
the exported json_metadata would gain a literal null entry, a real
change. Compare against a sentinel default instead, and pin the
absent-vs-null case for both authoritative keys.

sc-120011

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
@mikebridge

Copy link
Copy Markdown
Member Author

The codeant/bito finding on _changes_authoritative_colors is correct and fixed in 20f6d1d: an explicit color_scheme: null (or label_colors: null) compared equal to metadata.get(key)'s None default when the stored metadata lacked the key — yet the DAO writes every provided key, so the managed dashboard's exported json_metadata would have gained a literal null entry. The comparison now uses a missing-key sentinel (absent ≠ null), pinned by parametrized tests for both authoritative keys.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW

@bito-code-review

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

Copy link
Copy Markdown
Contributor

Code Review Agent Run #588cc4

Actionable Suggestions - 0
Additional Suggestions - 3
  • superset/commands/dashboard/update.py - 2
    • Colors sync 403 on empty label_colors · Line 331-338
      The frontend `storeDashboardColorConfig` always sends `label_colors: metadata.label_colors || {}`. For an externally managed dashboard whose stored json_metadata lacks `label_colors`, the incoming value is `{}`, and `{} != _METADATA_MISSING` is True, so `_changes_authoritative_colors` raises `DashboardForbiddenError` and the background colors sync fails with 403 — defeating the exemption this PR adds. The `_METADATA_MISSING` sentinel only covers the `null` case, not the `{}` normalization the frontend actually sends. Treat empty `{}`/`None` as no-change when the stored key is absent.
    • Use of assert detected · Line 320-320
      Replace `assert self._model` with explicit check. Also at lines 332 and 345.
  • superset/dashboards/schemas.py - 1
    • Stale docstring rationale · Line 489-495
      The docstring says "this schema raises on unknown fields, so the key is dropped here rather than removed from the accepted payload," but the field is now declared on line 501, so the schema would not raise on it. The rationale is stale and contradicts the code; it could mislead a maintainer into deleting the hook as redundant. Clarify that the field stays declared for the OpenAPI contract while the pre_load discard keeps it out of the loaded payload.
Review Details
  • Files reviewed - 15 · Commit Range: 86a792e..20f6d1d
    • superset/charts/schemas.py
    • superset/commands/chart/update.py
    • superset/commands/dashboard/update.py
    • superset/commands/dataset/refresh.py
    • superset/commands/dataset/update.py
    • superset/commands/utils.py
    • superset/dashboards/schemas.py
    • superset/datasets/schemas.py
    • superset/views/core.py
    • tests/integration_tests/charts/api_tests.py
    • tests/integration_tests/core_tests.py
    • tests/unit_tests/commands/chart/update_test.py
    • tests/unit_tests/commands/dataset/refresh_test.py
    • tests/unit_tests/commands/dataset/update_test.py
    • tests/unit_tests/commands/test_update_managed_externally.py
  • Files skipped - 1
    • UPDATING.md - 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

@mikebridge mikebridge closed this Sep 12, 2026
@mikebridge mikebridge reopened this Sep 12, 2026

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

Adversarial review of the server-side is_managed_externally enforcement. The core gate (raise_if_managed_externally, placed after the editorship check in all three update commands + dataset refresh + legacy Explore overwrite), the 403-as-editorship-denial choice, and the pre_load discard of the client-writable flag are all sound. One correctness bug that defeats the PR's own colors-sync carve-out (#1), one likely-unintended breakage of a local-only field (#2), and three smaller items below. (Automated review; posted by a human reviewer.)

Comment thread superset/commands/dashboard/update.py Resolved
Comment thread superset/commands/dashboard/update.py Resolved
Comment thread superset/commands/dashboard/update.py Resolved
Comment thread superset/charts/schemas.py Resolved
Comment thread UPDATING.md Resolved
…gle; pin the sibling gates

Review round (fitzee):

- The colors gate now compares EFFECTIVE authoritative color state:
  absent, explicit null, and empty ("" / {}) all encode "no colors".
  The background sync always sends label_colors: {} while a dashboard
  is merely viewed, so the previous byte-level sentinel comparison
  403'd every view of a managed dashboard whose metadata lacked the
  key — defeating the derived-colors carve-out in its most common
  case. This deliberately supersedes the earlier
  refuses-null-for-absent-key pin (an overcorrection): clearing a key
  that HOLDS state and setting a value on an absent key both still
  refuse (controls added).
- published-only updates pass the managed gate: the publish toggle is
  Superset-local visibility state, not content owned by the external
  source of truth; savePublished PUTs exactly {published}. Bundling
  any content field re-arms the gate (control pinned).
- The native-filters and chart-customizations sibling commands'
  inherited refusal of managed dashboards is now pinned as declared
  behavior (edit-time content writes, unlike the view-time colors
  sync).
- The thrice copy-pasted @pre_load is_managed_externally discard hook
  is now a shared DiscardIsManagedExternallyMixin in
  superset/utils/schema.py.
- UPDATING.md: blank line before the new heading (MD022).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
@bito-code-review

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

Copy link
Copy Markdown
Contributor

Code Review Agent Run #2e4536

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset/utils/schema.py - 1
    • Duplicate field declaration · Line 109-109
      `DiscardIsManagedExternallyMixin` re-declares `is_managed_externally` (line 109), which `BaseDashboardSchema` already declares (dashboards/schemas.py:460). For `DashboardPutSchema` the field is duplicated across two bases; identical today, but a future change to one would silently diverge. Consider declaring it only in the mixin and removing it from `BaseDashboardSchema`.
Review Details
  • Files reviewed - 6 · Commit Range: 20f6d1d..f3c23dc
    • superset/charts/schemas.py
    • superset/commands/dashboard/update.py
    • superset/dashboards/schemas.py
    • superset/datasets/schemas.py
    • superset/utils/schema.py
    • tests/unit_tests/commands/test_update_managed_externally.py
  • Files skipped - 1
    • UPDATING.md - 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

@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 f3c23dcfa9a0; no substantive findings. CI is green. Review was based on source and available test evidence; full local integration/browser validation was not performed.

Mike Bridge and others added 2 commits September 15, 2026 13:21
UPDATING.md keeps both entries (master's version-history edit-gate note
and this branch's externally-managed-update note). The views/core.py
conflict was a placement artefact — master made no change there — so the
legacy-overwrite is_managed_externally guard is retained as written.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01EA4MGEkUcDpyLReqjQBhPy
@richardfogaca
richardfogaca merged commit 6cfb331 into apache:master Sep 15, 2026
76 checks passed
@bito-code-review

Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped – PR Already Merged

Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.
No action is needed if you didn't intend to review it. To get a review, you can type /review in a comment and save it

mikebridge added a commit to mikebridge/superset that referenced this pull request Sep 15, 2026
apache#44025 landed the update-path is_managed_externally gate today and updated
every test in this file that existed then. This branch's soft-deleted-twin
test was written on a separate branch, so the two only met when master was
merged in: its bare MagicMock returns a truthy attribute, the new gate reads
that as externally managed, and the dataset is refused before the uniqueness
guidance it exists to assert.

Matches the pattern the other ten tests in this file already use.

Control: with the stub removed the test fails with DatasetForbiddenError;
restored, the file's 32 tests pass. Both states asserted by file content.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01EA4MGEkUcDpyLReqjQBhPy
villebro pushed a commit that referenced this pull request Sep 16, 2026
…date (#44025)

Co-authored-by: Claude Fable 5 <[email protected]>
Co-authored-by: Mike Bridge <[email protected]>
(cherry picked from commit 6cfb331)
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 requires:rebase Requires rebasing on top of current master size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants