Skip to content

fix(dashboard): reconcile position_json against membership on save - #44028

Merged
aminghadersohi merged 31 commits into
apache:masterfrom
mikebridge:sc-115325-position-json-reconcile
Oct 13, 2026
Merged

aminghadersohi merged 31 commits into
apache:masterfrom
mikebridge:sc-115325-position-json-reconcile

Conversation

@mikebridge

@mikebridge mikebridge commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

SUMMARY

position_json (the dashboard layout JSON) is a plain column with no
coordination against the dashboard_slices association. A chart hard-deleted
while it was a live dashboard member leaves a layout node referencing a chart id
that no longer resolves to any Slice row, and a restore-with-skips reproduces
the same divergence — a layout tile pointing at a chart absent from slices.
The divergence is invisible to the API consumer and accumulates: every save
writes meta.uuid = None into the dangling slot.

This reconciles position_json against membership on write. A CHART layout
node whose chartId does not resolve to any Slice row is swapped in place for
a markdown placeholder — keeping the node id, children, and geometry and
replacing only type+meta. This mirrors the frontend swapUnreachableChartSlots
(#41551) and the runtime MissingChart placeholder, persisting what the
client already renders rather than re-deriving it on every load.

Key design decisions:

  • Soft-deleted members are preserved on ordinary saves. The dangling check keys on "chartId not
    resolvable to any Slice row with the soft-delete visibility filter
    bypassed
    ", so a soft-deleted (recoverable) member — whose dashboard_slices
    junction row still exists — is never treated as dangling. Only genuinely-absent
    (hard-deleted / never-existed) references are repaired. The existing
    test_set_dash_metadata_preserves_soft_deleted_members stays green.

  • Both write paths are covered. DashboardDAO.set_dash_metadata (positions in
    json_metadata, reusing its already-resolved uuid_map) and the raw
    position_json-field PUT in UpdateDashboardCommand.run (which resolves
    membership itself via reconcile_position_json).

  • The placeholder text is a plain literal, not gettext. position_json is
    persisted, shared data rendered verbatim to every viewer, so translating it to
    the saving user's request locale would bake one language into content shown to
    everyone. Per-viewer localization stays the frontend's render-time job.

  • Copying a dashboard AND its charts does not share archived originals. An
    archived member's slot in the copy becomes a markdown placeholder saying
    "This archived chart was not copied.", preserving its position and size but
    dropping the chart ID/UUID and membership link. Restoring the original later
    does not attach it to the copy. Live charts are still cloned; the source,
    ordinary save/restore reattachment and copy-without-charts are unchanged.

  • Known copy limitation: a layout referencing a live chart outside the
    source dashboard's membership still fails closed when copying charts. A
    normal save can synchronize membership first. This PR does not choose a new
    clone/placeholder policy for those nonmember slots. MCP reports this as a
    source-layout repair error, which is imprecise for a membership mismatch.
    The owner decision covers archived members only, not live nonmember slots.

  • Capacity follow-up: direct layout-ID IN lookups remain unbounded; their
    previously recorded non-GA-blocking follow-up is not claimed resolved.

Refs: sc-115325. Found during the #42469 (version-restore) review but
pre-existing product-wide behavior, not a restore regression.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

No UI screenshot — this is a backend reconcile. Behaviorally: a dashboard whose
layout references a hard-deleted chart previously kept a broken CHART tile
(meta.uuid = null) accumulating on every save; after this change, saving swaps
that slot to a markdown "This chart no longer exists." tile (the same content the
frontend already renders at read time for such a slot).

TESTING INSTRUCTIONS

  1. Create a dashboard with a chart, then hard-delete the chart.
  2. Save the dashboard (PUT). Observe the layout node for the deleted chart is now
    a markdown placeholder rather than a dangling CHART node, and
    position_json no longer references the absent chart id.
  3. Repeat with a soft-deleted chart — its tile must be preserved (still a
    CHART node with its uuid), confirming recoverable members are not repaired.

Automated: pytest tests/unit_tests/dao/dashboard_test.py (both write paths,
live + soft-deleted + genuinely-absent chartIds, non-dict-position_json guard,
and a reverted-fix control) and
pytest tests/integration_tests/dashboards/api_tests.py -k reconciles_dangling
(a PUT end-to-end pinning that run() invokes the reconcile).

Additional copy verification at 058a0ef5e0348a1305d109d81e6c999bd2bb0583:
the archived-copy regression failed in both cached/fresh relationship cases
before the fix and passes after it. It runs the real restore command and checks
no reattachment to the copy, then saves the copy again. Copy-without-charts and
legacy string/float live-chart clone identity remain covered. Local affected
unit suites: 48 passed; targeted SQLite dashboard API/DAO integration:
7 passed; complete branch changed-file pre-commit passed. Full-branch Python
annotation review and independent Claude exact-snapshot review are recorded;
these local results are not a current-head CI or full-repository test claim.

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

@codecov

codecov Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.77%. Comparing base (1b35374) to head (c5e5065).
⚠️ Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
superset/daos/dashboard.py 98.78% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #44028      +/-   ##
==========================================
- Coverage   82.80%   82.77%   -0.03%     
==========================================
  Files        3016     3015       -1     
  Lines      192521   192343     -178     
  Branches    44842    44720     -122     
==========================================
- Hits       159409   159212     -197     
- Misses      30079    30099      +20     
+ Partials     3033     3032       -1     
Flag Coverage Δ
hive 35.37% <15.00%> (-0.02%) ⬇️
mysql 53.86% <85.00%> (+0.07%) ⬆️
postgres 53.87% <85.00%> (+0.07%) ⬆️
presto 37.15% <15.00%> (-0.02%) ⬇️
python 86.48% <99.00%> (+0.01%) ⬆️
sqlite 53.61% <85.00%> (+0.07%) ⬆️
unit 80.10% <92.00%> (+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.

@mikebridge
mikebridge force-pushed the sc-115325-position-json-reconcile branch from 85e1546 to 0bccd7f Compare September 8, 2026 23:01
@netlify

netlify Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

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

@mikebridge
mikebridge marked this pull request as ready for review September 8, 2026 23:41
@mikebridge

Copy link
Copy Markdown
Member Author

@aminghadersohi — ready for review (undrafted). CI green across all dialects on 0bccd7fd7f (test-postgres/mysql/sqlite/unit all pass).

This reconciles dashboard position_json against dashboard_slices membership on save: a CHART layout node referencing a chart absent from every Slice row (hard-deleted / never existed) is swapped in place for a markdown placeholder, mirroring the frontend swapUnreachableChartSlots (#41551). Soft-deleted members are preserved by construction (resolution bypasses only the soft-delete filter, not existence), and both write paths are covered (set_dash_metadata + the raw position_json PUT).

It's had a 5-lens local review + an independent cross-model pass; the latter caught and closed input-hardening edge cases (malformed-JSON layout nodes, chartId=0, non-object position_json) — see the SUMMARY and the tests (both paths, soft-delete-preserved, reverted-fix control, a parameterized non-object-PUT test, and a PUT wiring test). Appreciate a look when you have a moment.

@bito-code-review

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

Copy link
Copy Markdown
Contributor

Code Review Agent Run #33d9b5

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: 0bccd7f..0bccd7f
    • superset/commands/dashboard/update.py
    • superset/daos/dashboard.py
    • tests/integration_tests/dashboards/api_tests.py
    • tests/unit_tests/dao/dashboard_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

@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 position_json membership reconciliation. This is a carefully written, well-tested, defensive PR — the soft-delete-bypass for valid_chart_ids, the chartId==0 handling, the bool/non-dict/malformed-node guards, doing the repair before the uuid loop, the plain-literal (non-gettext) placeholder, and both write paths all check out, and it mirrors the frontend swapUnreachableChartSlots/layoutChartId faithfully. No high-severity bug. Two secondary notes below — one edge/legacy-data regression, one redundancy. (Automated review; posted by a human reviewer.)

chart_id
for value in positions.values()
if isinstance(value, dict)
if (chart_id := _layout_chart_id(value)) is not None

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.

Edge/legacy regression: a non-int chartId (float/string) is now silently unlinked from dashboard.slices and left as an orphaned CHART node. _layout_chart_id requires isinstance(chart_id, int) (line 111), so a CHART node whose meta.chartId is 123.0 (float) or "123" (string) — from legacy data, an import, or a JSON round-trip — now returns None. The old code used value.get('meta',{}).get('chartId') with no type check, so the id landed in slice_ids and (at least for a float, and for strings on lax backends like SQLite) still resolved via Slice.id.in_(...), keeping the chart in the rebuilt dashboard.slices.

Now that node is excluded from slice_ids → the wholesale dashboard.slices = current_slices rebuild drops its dashboard_slices junction row → the chart is unlinked on the next save. And because _layout_chart_id returns None, _repair_dangling_chart_nodes also skips it, so the node isn't converted to a placeholder either — it's left as a permanent orphan CHART node no longer backed by membership. The frontend never emits non-int chartIds, so this is legacy/imported-data only, not a mainstream regression — but worth either coercing numeric chartIds (int(chart_id) when it's a float/digit-string) or logging/repairing such nodes rather than silently dropping them.

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.

Fixed in 7e4c47b — integral floats (123.0) and digit strings ("123") are now coerced to the int in _layout_chart_id, so a live chart in either form is recognised and kept, while an absent id in those forms is still repaired; fractional floats, non-digit strings, and bools stay None. A parametrized unit test covers every form, and a reconcile test pins the live-kept / absent-repaired split. Good catch on the orphan-tile mechanics (excluded from the rebuild AND unrepairable) — that is exactly why coercion rather than repair was the right fix.

Comment thread superset/commands/dashboard/update.py Outdated
json.loads(position_json)
)
positions: object = json.loads(position_json)
reconcile_position_json(positions, self._model.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.

Redundant reconcile whose result is discarded when a PUT also sends json_metadata.positions. When both the raw position_json field and json_metadata (which carries positions — the frontend puts them there, dashboardState.ts:754-757) are present, this path reconciles the raw field and DashboardDAO.update writes it, but set_dash_metadata then re-reconciles its own positions and overwrites dashboard.position_json (daos line ~515/388). So the work here — including the _existing_chart_ids DB query — is thrown away, and the raw position_json field is silently ignored in favor of json_metadata.positions for that save. No correctness harm (set_dash_metadata reconciles too), and the standard frontend save sends only json_metadata.positions so this path doesn't fire there — but for an API client sending both, the raw-field reconcile is dead work and the field-vs-metadata precedence is undocumented. Consider skipping the raw reconcile when json_metadata with positions is present, or noting the precedence.

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.

Fixed in 7e4c47b — the raw-field reconcile now runs only when json_metadata does not carry positions; when it does, set_dash_metadata reconciles and writes those and the raw field is superseded, so the dead work (including its membership query) is skipped. The precedence is recorded in the comment, json_metadata is parsed once and handed to set_dash_metadata, and an integration test pins both the precedence and that the raw reconcile is not invoked on a PUT sending both.

…c-115325)

`position_json` (the layout JSON) is a plain column with no coordination
against `dashboard_slices`. A chart hard-deleted while it was a live member
leaves a layout node referencing an id that no longer resolves to any Slice
row, and a restore-with-skips reproduces the same divergence — a layout tile
pointing at a chart absent from `slices`. The divergence is invisible to the
API consumer and accumulates: every save writes `meta.uuid = None` into the
dangling slot.

Reconcile on write: a CHART node whose chartId does not resolve to any Slice
row (resolved with the soft-delete visibility filter bypassed, so recoverable
soft-deleted members are preserved) is swapped in place for a markdown
placeholder — keeping the node id, children, and geometry and replacing only
`type`+`meta`. This mirrors the frontend `swapUnreachableChartSlots` (apache#41551)
and the runtime MissingChart placeholder, persisting what the client already
renders rather than re-deriving it every load.

The placeholder text is a plain literal, not `gettext`: `position_json` is
persisted, shared data rendered verbatim to every viewer, so translating it to
the saving user's request locale would bake one language into content shown to
everyone. Per-viewer localization stays the frontend's render-time job.

Both write paths are covered:
- `DashboardDAO.set_dash_metadata` (positions in json_metadata) — repairs using
  the `uuid_map` it already resolves, before the uuid-stamping loop so a
  repaired node is skipped there instead of getting `meta.uuid = None`.
- the raw `position_json`-field PUT in `UpdateDashboardCommand.run` — reconciles
  via `reconcile_position_json`, which resolves membership itself.

Keying on "absent from every Slice row" preserves soft-deleted members by
construction and keeps `test_set_dash_metadata_preserves_soft_deleted_members`
green.

Tests:
- unit (dao): both helper paths with live + soft-deleted + genuinely-absent
  chartIds; a reverted-fix control (neutering the repair fails both).
- integration (api): a raw-`position_json` PUT with a dangling chartId asserts
  the persisted layout node is a markdown placeholder — pinning that `run()`
  actually invokes `reconcile_position_json` (a helper-only unit test would
  stay green if a refactor dropped the call).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01267VBWbvWTNZUg9GvXKgkC
mikebridge pushed a commit to mikebridge/superset that referenced this pull request Sep 14, 2026
…cile when metadata carries positions

fitzee review on apache#44028:

- `_layout_chart_id` required `isinstance(chart_id, int)`, so a CHART node whose
  `meta.chartId` was `123.0` (float) or `"123"` (digit string) — legacy data,
  an import, a JSON round-trip — returned None. The pre-reconcile code passed
  those straight into `Slice.id.in_(...)`; returning None now excluded the
  node from the membership rebuild (unlinked on the next save) AND, with no id
  to resolve, skipped its repair — a permanent orphan tile. Integral floats
  and digit strings are now coerced to the int; fractional floats, non-digit
  strings, and bools stay None. Parametrized unit test covers every form; a
  reconcile test proves a LIVE chart referenced in either numeric form is
  kept while an ABSENT id in those forms is still repaired.
- When a PUT sends both a raw `position_json` and `json_metadata` carrying
  `positions`, `set_dash_metadata` reconciles and writes the metadata
  positions and overwrites `position_json`, so the raw-field reconcile
  (including its membership query) was dead work whose result was discarded,
  and the precedence was undocumented. The raw reconcile now runs only when
  `json_metadata` does not carry positions; the precedence
  (metadata positions supersede the raw field) is recorded in the comment.
  `json_metadata` is parsed once and handed to `set_dash_metadata`. Integration
  test pins both the precedence and that the raw reconcile is not invoked.

Rebased onto master. Unit 24/24; reconcile PUT integration tests 3/3 on
Postgres.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01267VBWbvWTNZUg9GvXKgkC
@mikebridge
mikebridge force-pushed the sc-115325-position-json-reconcile branch from 0bccd7f to 0aec287 Compare September 14, 2026 16:11
…cile when metadata carries positions

fitzee review on apache#44028:

- `_layout_chart_id` required `isinstance(chart_id, int)`, so a CHART node whose
  `meta.chartId` was `123.0` (float) or `"123"` (digit string) — legacy data,
  an import, a JSON round-trip — returned None. The pre-reconcile code passed
  those straight into `Slice.id.in_(...)`; returning None now excluded the
  node from the membership rebuild (unlinked on the next save) AND, with no id
  to resolve, skipped its repair — a permanent orphan tile. Integral floats
  and digit strings are now coerced to the int; fractional floats, non-digit
  strings, and bools stay None. Parametrized unit test covers every form; a
  reconcile test proves a LIVE chart referenced in either numeric form is
  kept while an ABSENT id in those forms is still repaired.
- When a PUT sends both a raw `position_json` and `json_metadata` carrying
  `positions`, `set_dash_metadata` reconciles and writes the metadata
  positions and overwrites `position_json`, so the raw-field reconcile
  (including its membership query) was dead work whose result was discarded,
  and the precedence was undocumented. The raw reconcile now runs only when
  `json_metadata` does not carry positions; the precedence
  (metadata positions supersede the raw field) is recorded in the comment.
  `json_metadata` is parsed once and handed to `set_dash_metadata`. Integration
  test pins both the precedence and that the raw reconcile is not invoked.

Rebased onto master. Unit 24/24; reconcile PUT integration tests 3/3 on
Postgres.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01267VBWbvWTNZUg9GvXKgkC
@mikebridge
mikebridge force-pushed the sc-115325-position-json-reconcile branch from 0aec287 to 7e4c47b Compare September 14, 2026 16:13
Comment thread superset/commands/dashboard/update.py Resolved
Comment thread superset/daos/dashboard.py Resolved
Comment thread superset/daos/dashboard.py Resolved
@mikebridge mikebridge closed this Sep 14, 2026
@mikebridge mikebridge reopened this Sep 14, 2026
…ull; refuse malformed CHART nodes

codeant review on apache#44028, two real findings:

- The precedence skip tested only for the `positions` KEY in json_metadata,
  but set_dash_metadata skips a null `positions` entirely
  (`data.get("positions") is not None`), so a PUT sending
  `json_metadata: {"positions": null}` alongside a raw `position_json` skipped
  the raw reconcile AND wrote nothing from metadata — the dangling raw layout
  was persisted as-is. The skip now mirrors the DAO's exact test, so the raw
  field is reconciled whenever metadata will not supersede it. Integration
  test added.

- A CHART node whose `chartId` cannot be resolved was excluded from the
  wholesale `dashboard.slices` rebuild, silently detaching the chart it
  referenced. The pre-reconcile code failed that save too (a 500 from the
  bad `IN` value); ignoring the node is right for the REPAIR path, which
  never rebuilds membership, but not here. `_reject_malformed_chart_nodes`
  now fails the metadata path closed with a DashboardInvalidError naming the
  slot(s) — a 422 through the existing API mapping — before any membership
  is touched. Unit test (memberships untouched by the refusal) and
  integration test (422 naming the node, memberships intact) added.

Refuted, with evidence, on the thread: the "oversized IN from a huge layout"
concern — the pre-existing membership rebuild issues the identical
`Slice.id.in_(slice_ids)` over the same layout ids, so the reconcile adds no
new surface or bound.

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

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

Copy link
Copy Markdown
Contributor

Code Review Agent Run #e62fca

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset/daos/dashboard.py - 1
    • Misleading duplicate error · Line 526-526
      `_reject_malformed_chart_nodes` now raises `DashboardInvalidError` from `set_dash_metadata`, which is reached by `copy_dashboard` on the duplicate path. The tool's `except DashboardInvalidError` in `duplicate_dashboard.py` maps that to "Provide a non-empty dashboard_title", a misleading message for a malformed chart node. Consider distinguishing the two failure modes.
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • superset/daos/dashboard.py - 1
Review Details
  • Files reviewed - 4 · Commit Range: bc204db..2c3a7d9
    • superset/commands/dashboard/update.py
    • superset/daos/dashboard.py
    • tests/integration_tests/dashboards/api_tests.py
    • tests/unit_tests/dao/dashboard_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

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

P2 — copying with duplicate charts fails for a deleted-chart layout slot. copy_dashboard maps every layout chart ID through old_to_new_slice_ids.get(...); a hard-deleted chart has no mapping and becomes None. The new validation at daos/dashboard.py:526 then rejects it before reconciliation. Could we convert unmapped slots to geometry-preserving placeholders in the copy path and add a live-chart + deleted-slot copy regression test, while retaining strict save-payload validation? This is based on caller/callee and comparison-base inspection, not a runtime reproduction.

Copying a dashboard with `duplicate_slices=True` remaps every layout
chart id through the clone mapping. A chart hard-deleted while it was a
member has no row to clone and so no mapping entry, and the remap wrote
`old_to_new_slice_ids.get(old_id)` unconditionally — turning a
valid-but-dangling id into `None`. The strict malformed-node validation
this PR adds then refused the copy, so a dashboard carrying such a slot
could no longer be duplicated at all.

Reconcile the submitted positions against the original dashboard before
cloning, while the old ids still identify their rows and no clone ids
exist to confuse the existence lookup. The absent slot becomes the same
markdown placeholder the raw-layout path produces, keeping its node id,
parent/child structure and geometry, and the remap below skips it because
it no longer carries a chartId. A soft-deleted (recoverable) member is
still not repaired away — `_existing_chart_ids` bypasses the visibility
filter — and an originally malformed CHART node is still rejected.

Reported by Richard Fogaça in review of apache#44028.

Adds a copy regression covering a live chart plus a hard-deleted slot
(clone referenced and uuid rewritten, placeholder geometry preserved, no
null chartId, membership is the clones only, source row unmutated) and
retains a negative pinning that a malformed chartId still raises. Also
annotates the locals this PR added and gives the two new helpers
complete one-line docstring summaries, per review.

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

Copy link
Copy Markdown
Member Author

You're right, and thanks for catching it. The copy loop writes old_to_new_slice_ids.get(old_id) unconditionally at daos/dashboard.py:713, so a chart hard-deleted while it was a member — no row, no clone, no mapping entry — becomes chartId: None, and the new _reject_malformed_chart_nodes then refuses the copy at :526. Fixed in 3f1f30f by reconciling the submitted positions against the original dashboard before cloning, while the old ids still identify their rows and no clone ids exist to confuse the existence lookup: the dangling slot becomes the same markdown placeholder the raw-layout path produces (node id, parents/children and geometry preserved), and the remap skips it because it no longer carries a chartId. The strict validation is unchanged — an originally malformed chartId still raises — and a soft-deleted, recoverable member is still not repaired away. Added a copy regression with a live chart plus a hard-deleted slot, asserting the clone is referenced with its uuid, the placeholder keeps its geometry, no CHART node has a null id, membership is the clones only, and the source dashboard is left untouched; kept a negative test that a malformed id is still rejected.

@bito-code-review

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

Copy link
Copy Markdown
Contributor

Code Review Agent Run #64e8ca

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: 2c3a7d9..3f1f30f
    • superset/commands/dashboard/update.py
    • superset/daos/dashboard.py
    • tests/integration_tests/dashboards/dao_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

@aminghadersohi
aminghadersohi self-requested a review September 16, 2026 06:26
Merge origin/master and address rusackas review findings on apache#44028.
Deduplicate detached chart references before converting missing charts to
placeholders, and persist integer chart IDs for native/cross-filter scope.
Preserve empty legacy copy slots and document detached-slot reattachment.
Add real save-path regression coverage for both supported payload forms.
@mikebridge

Copy link
Copy Markdown
Member Author

Thanks for identifying both cases. Addressed in 751be2b010c0677bf6f47139fd4110e5c12c89dc, which also merges master b98e19f6eb23784db5d874346b4a14dd36eb786d.

Chart IDs are now normalized and written back before layout repair. Detached duplicates are deduplicated while they still carry CHART identity; only remaining absent references become placeholders. The stored integer IDs are then available to both native and cross-filter scope readers. Red-first tests exercise both position_json and json_metadata.positions, including string/integral-float IDs, SQL readback, and both scope readers.

One deliberate legacy-slot distinction: a detached slot with a null or missing chart ID has no identity to deduplicate. This retains it as a placeholder in a reachable row, preserving its size; master previously dropped it. The existing null-slot save behavior remains supported, and the docs explicitly describe reattachment rather than claiming its detached position survives.

The final focused suite has 115 passing tests, branch hooks pass, and the exact pushed tree received independent review. The PR remains draft; this is a status update on the two fixes.

@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Oct 1, 2026
@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Oct 2, 2026
Keep the dashboard copy layout validation note alongside master's semantic bundle export guidance. Retain both auto-merged dashboard API/OpenAPI additions for the conductor's independent data-write review.
@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Oct 3, 2026
Bring in the upstream importer typing repair and current master without changing the dashboard copy or reconciliation behavior. Keep the draft branch local for exact-tree data-write review.
@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Oct 6, 2026
…json-reconcile

# Conflicts:
#	superset/commands/dashboard/update.py
@github-actions github-actions Bot added requires:rebase Requires rebasing on top of current master and removed requires:rebase Requires rebasing on top of current master labels Oct 8, 2026
@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Oct 8, 2026
@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Oct 9, 2026
@github-actions github-actions Bot added requires:rebase Requires rebasing on top of current master and removed requires:rebase Requires rebasing on top of current master labels Oct 9, 2026
@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Oct 9, 2026
@mikebridge
mikebridge marked this pull request as ready for review October 9, 2026 17:18
@codeant-ai-for-open-source

Copy link
Copy Markdown
Contributor

CodeAnt PR Risk: Medium Risk

  • The PR needs attention before merging because raw layout saves now query chart IDs across the submitted layout.
  • The existing membership-query rebuttal does not cover the raw position_json path; confirm request limits or bound the lookup for very large layouts.

Assessed commit: c5e50659cd54

@aminghadersohi
aminghadersohi merged commit f154d23 into apache:master Oct 13, 2026
118 checks passed
villebro added a commit that referenced this pull request Nov 2, 2026
…cess part of #45535)

Reduced backport of #45535 for 7.0: generate_dashboard and
add_chart_to_existing_dashboard refuse charts the caller can't access
(security_manager.can_access_chart), with their tests.

Left out because they depend on code that only exists on master:
- the layout-chart check in generate_dashboard, which needs
  superset.daos.dashboard._layout_chart_id from #44028, and its
  test_generate_dashboard_refuses_unlisted_layout_chart test;
- test_chart_access_query_count.py, which calls the tool through
  inspect.unwrap and needs master's FastMCP 4 tool wrapping (#45639);
- the docs change (docs deploy from master).

(cherry picked from commit eee2c16, reduced)
villebro added a commit that referenced this pull request Nov 2, 2026
…ver (access-check part of #45538)

Reduced backport of #45538 for 7.0. Saving a dashboard layout (update,
create, copy) refuses with a 422 a chart the layout adds that the caller
can't read, since dashboard membership feeds the datasource grant for
dashboard viewers (VIEWER_PROMISCUOUS_MODE) and embedded guests. Charts
already on the dashboard are accepted, and a copy accepts the source's
charts (or its own clones). UpdateDashboardCommand runs the check in
validate(), before run() deactivates reports and emails their owners.

Adapted to 7.0, which lacks the position_json reconciliation from #44028:
- layout chart ids are read the way 7.0's set_dash_metadata already reads
  them, instead of through #44028's _layout_chart_id and
  _reject_malformed_chart_nodes;
- DashboardLayoutInvalidError, added on master by #44028, is added here;
- the archived-member adjustment and #45538's tests, which target #44028's
  archived handling and integration fixtures, are replaced by 7.0 unit tests
  covering refusal, existing members, copy, and the update pre-check.

(cherry picked from commit 138a320, reduced)
villebro added a commit that referenced this pull request Nov 14, 2026
…chart's own requests (reduced backport of #44215)

The security manager change applies as is. On 7.0 the copy and native-filter
checks build on the reduced #45538 layout check rather than master's #44028
and #45800 helpers: a copy checks the source charts it carries (all of them
when duplicating or without a layout, else those its layout places) and its
native-filter targets, and the update command checks new filter targets
before its side effects. The dashboard datasets endpoint passes the grant to
the serializer, since 7.0's DAO takes no access callback. Tests for files
absent on 7.0 are left out, and 7.0's copy test now expects the refusal.

(cherry picked from commit 2645396, reduced)
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/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants