You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "mikebridge (via GitHub)" <gi...@apache.org> on 2026/09/03 23:24:11 UTC
[PR] fix(versioning): bound dashboard related history by the chart attach window [superset]
mikebridge opened a new pull request, #43837:
URL: https://github.com/apache/superset/pull/43837
### SUMMARY
A dashboard's version-history related items should include a member chart's edits **only while that chart was attached** to the dashboard. In practice, a chart edit made **after** the chart was removed from the dashboard still surfaced as a `Chart updated` related entry — under both "All changes" and "Related items only".
**Root cause** (`superset/versioning/activity/queries.py::charts_attached_to_dashboard`): each attachment window was derived from the `dashboard_slices_version` shadow's `transaction_id` / `end_transaction_id`, with `operation_type = 2` (DELETE) rows excluded as "phantom detachment rows". But sqlalchemy-continuum **never closes an association shadow row's `end_transaction_id`** — its unit-of-work only *inserts* association versions (`create_association_versions`); the validity backfill that sets `end_transaction_id` runs for parent objects, not for M2M links. So the attach (INSERT) row's `end_transaction_id` stays `NULL` for the association's entire life, every derived window was open-ended `[attach_tx, None)`, and the DELETE row that actually carries the detach transaction was exactly the row being discarded. Result: any edit of a chart that was *ever* on the dashboard fell inside the (open) window.
**Fix**: pair the INSERT/DELETE rows. A new pure `_attachment_windows` helper walks the shadow rows per slice in transaction order — opening a window at each INSERT and closing it at the next DELETE's `transaction_id` (open-ended while the chart is still attached; no window at all when a chart is added and removed in the same save, which never reached a committed dashboard state). `charts_attached_to_dashboard` now fetches `operation_type` and delegates the windowing. Downstream scope-resolution, intersection, and union are unchanged.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Backend-only. Before: with chart X attached at t1, edited at t2, removed at t3, edited again at t4, the dashboard's related history showed the t4 edit. After: the window is `[t1, t3)`, so the t2 edit (while attached) is included and the t4 edit (after removal) is excluded.
### TESTING INSTRUCTIONS
`pytest tests/unit_tests/versioning/test_activity.py -k attachment_windows` — covers the after-removal exclusion (the ticket's oracle: an INSERT@t1 / DELETE@t3 pair excludes an edit at t4), a still-attached open window, reattach cycles, row-order independence, add-and-remove-in-one-save, and per-slice separation.
Manual: put a chart on a dashboard, edit it (save), remove it from the dashboard (save), edit it again (save); open the dashboard's version history — only the edit made while the chart was on the dashboard appears as a related `Chart updated`.
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] 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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(versioning): bound dashboard related history by the chart attach window [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #43837:
URL: https://github.com/apache/superset/pull/43837#issuecomment-5533660195
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/43837?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `0%` with `19 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 57.49%. Comparing base ([`3258f5f`](https://app.codecov.io/gh/apache/superset/commit/3258f5fa3f6b1eaa87624e7716606a1f6933abd3?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`305ccae`](https://app.codecov.io/gh/apache/superset/commit/305ccae2e71bcf089ac469f155ac6ea834e9855d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/43837?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [superset/versioning/activity/queries.py](https://app.codecov.io/gh/apache/superset/pull/43837?src=pr&el=tree&filepath=superset%2Fversioning%2Factivity%2Fqueries.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvdmVyc2lvbmluZy9hY3Rpdml0eS9xdWVyaWVzLnB5) | 0.00% | [19 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/43837?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
> :exclamation: There is a different number of reports uploaded between BASE (3258f5f) and HEAD (305ccae). Click for more details.
>
> <details><summary>HEAD has 10 uploads less than BASE</summary>
>
>| Flag | BASE (3258f5f) | HEAD (305ccae) |
>|------|------|------|
>|python|14|4|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #43837 +/- ##
===========================================
- Coverage 79.42% 57.49% -21.93%
===========================================
Files 2895 2895
Lines 167947 167957 +10
Branches 38896 38901 +5
===========================================
- Hits 133388 96563 -36825
- Misses 32059 70495 +38436
+ Partials 2500 899 -1601
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/43837/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [hive](https://app.codecov.io/gh/apache/superset/pull/43837/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `37.78% <0.00%> (-0.01%)` | :arrow_down: |
| [mysql](https://app.codecov.io/gh/apache/superset/pull/43837/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [postgres](https://app.codecov.io/gh/apache/superset/pull/43837/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [presto](https://app.codecov.io/gh/apache/superset/pull/43837/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.67% <0.00%> (-0.01%)` | :arrow_down: |
| [python](https://app.codecov.io/gh/apache/superset/pull/43837/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.72% <0.00%> (-44.15%)` | :arrow_down: |
| [sqlite](https://app.codecov.io/gh/apache/superset/pull/43837/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [unit](https://app.codecov.io/gh/apache/superset/pull/43837/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/43837?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(versioning): bound dashboard related history by the chart attach window [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi merged PR #43837:
URL: https://github.com/apache/superset/pull/43837
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(versioning): bound dashboard related history by the chart attach window [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43837:
URL: https://github.com/apache/superset/pull/43837#issuecomment-5534881507
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**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 <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(versioning): bound dashboard related history by the chart attach window [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43837:
URL: https://github.com/apache/superset/pull/43837#issuecomment-5533415350
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(versioning): bound dashboard related history by the chart attach window [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on code in PR #43837:
URL: https://github.com/apache/superset/pull/43837#discussion_r3931305240
##########
superset/versioning/activity/queries.py:
##########
@@ -118,14 +119,66 @@ def first_tracked_tx(
# ---- Phase A: relationship-traversal queries ------------------------------
+# ``operation_type`` values on a Continuum association shadow row
+# (sqlalchemy_continuum.operation.Operation): INSERT attaches, DELETE detaches.
+# UPDATE never occurs for a pure M2M association (there is nothing to update on
+# a (dashboard, slice) pair); if it ever appeared it is ignored — neither
+# opening nor closing a window — so an open attachment simply continues.
+# These mirror the library enum's numeric values; ``test_m2m_op_constants_match_
+# continuum`` pins them so a Continuum renumber fails loudly rather than silently.
+_M2M_OP_INSERT = 0
+_M2M_OP_DELETE = 2
+
+
+def _attachment_windows(
+ rows: list[tuple[int, int, int]],
+) -> list[tuple[int, Window]]:
+ """Pair INSERT / DELETE association-version rows into ``[attach, detach)``
+ windows, one per attachment episode.
+
+ Each row is ``(slice_id, transaction_id, operation_type)``. Continuum
+ **never closes** an association shadow row's ``end_transaction_id`` — its
+ unit-of-work only *inserts* association versions
+ (``create_association_versions``); the validity backfill that sets
+ ``end_transaction_id`` runs for parent objects, not for M2M links. So the
+ detach boundary lives on the DELETE row's ``transaction_id``, not on the
+ attach row's ``end_transaction_id`` (which stays NULL for the association's
+ whole life). An INSERT opens a window; the next DELETE closes it at its
+ transaction id; an attachment with no following DELETE stays open (the
+ chart is still on the dashboard). A DELETE at the same transaction as its
+ open (add-and-remove in one save) yields no window — the chart was never
+ on a committed dashboard state.
+ """
+ result: list[tuple[int, Window]] = []
+ # operation_type is part of the sort key so that, within one transaction,
+ # INSERT (0) sorts before DELETE (2): an add-and-remove in a single save is
+ # then seen open-before-close and collapses to no window (the DELETE finds
+ # ``tx == open_tx``, not ``>``). Do not drop it from the key.
+ rows_sorted = sorted(rows, key=lambda r: (r[0], r[1], r[2]))
+ for slice_id, group in groupby(rows_sorted, key=lambda r: r[0]):
+ open_tx: int | None = None
+ for _slice_id, tx, operation_type in group:
+ if operation_type == _M2M_OP_DELETE:
+ if open_tx is not None and tx > open_tx:
+ result.append((slice_id, Window(open_tx, tx)))
+ open_tx = None
+ elif operation_type == _M2M_OP_INSERT and open_tx is None:
Review Comment:
Question on the `and open_tx is None` guard, prompted by bito's note — I think it is a real edge case, so here it is with the trace.
The sort key puts INSERT(0) before DELETE(2) within a transaction, which makes add-and-remove-in-one-save collapse correctly (your test covers it). But the mirror case — *remove and re-add* in one save, while the chart was already attached — goes wrong:
```
rows = [(7, 3, 0), (7, 5, 2), (7, 5, 0)] # attached@3; removed+re-added@5
sorted = [(7, 3, 0), (7, 5, 0), (7, 5, 2)]
open_tx = 3 # INSERT@3
INSERT@5 -> ignored # open_tx is not None
DELETE@5 -> 5 > 3 # emits Window(3, 5), open_tx = None
result: [(7, Window(3, 5))]
```
The chart is still on the dashboard, but the window is closed at 5, so every later edit drops out of `_resolve_dashboard_scope`. That is this PR's bug inverted, and it is a behavioural change: the old code left the window open here (accidentally, but with the right outcome).
How reachable is it? I could not construct a concrete save path that emits this ordering — `dashboard.slices = current_slices` (`daos/dashboard.py:374`) is a wholesale reassignment whose collection diff nets an unchanged member out to no statement at all. But the schema explicitly anticipates the same-tx pair: `operation_type` is in the primary key precisely for it, and the migration says so in as many words (`56cd24c07170`, lines 512-515) — *"a single transaction can in principle produce both INSERT and DELETE shadows for the same (dashboard_id, slice_id) pair"*.
The genuine difficulty is that `{INSERT@t, DELETE@t}` is ambiguous in isolation: add-then-remove and remove-then-re-add produce identical rows. But `open_tx` disambiguates it — if a window is already open, an INSERT at the same tx can only be a re-add, since you cannot attach something already attached. So something like:
```python
elif operation_type == _M2M_OP_INSERT and (open_tx is None or ...):
```
keeping the window open when the same-tx INSERT follows a DELETE. Entirely your call whether it is worth handling versus documenting as out of scope — I would be happy with a comment saying the ordering is deliberate and why.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org