codeant-ai-for-open-source[bot] commented on code in PR #42469:
URL: https://github.com/apache/superset/pull/42469#discussion_r3673642531
##########
superset/versioning/utils.py:
##########
@@ -18,12 +18,65 @@
from __future__ import annotations
+from collections.abc import Iterator
+from contextlib import contextmanager
from typing import Any
import sqlalchemy as sa
+from flask import current_app
from sqlalchemy.orm import Session
+def capture_enabled() -> bool:
+ """Whether ``ENABLE_VERSIONING_CAPTURE`` is on for the current app.
+
+ The single gate shared by the read helpers (which degrade to inert
+ responses when off) and the write side (which must refuse: with
+ Continuum's write listeners detached, a restore would mutate the live
+ entity with no new version row — a destructive, untracked write that
+ violates the append-only contract).
+
+ Operational constraint: this reads config at call time, but the
+ Continuum listeners themselves attach or detach only when
+ ``init_versioning()`` runs at startup. The two agree only because the
+ flag is static per-process — flipping it at runtime (dynamic config
+ reload, a future admin toggle) without re-running ``init_versioning()``
+ would let this gate pass while listeners stay detached, producing
+ exactly the untracked write it exists to prevent. Restart the process
+ (or re-run ``init_versioning()``) after changing the flag.
+ """
+ return bool(current_app.config.get("ENABLE_VERSIONING_CAPTURE", False))
Review Comment:
**Suggestion:** The gate reads the mutable Flask configuration on every
request, but Continuum's write listeners are attached or detached only by
`init_versioning()` during initialization. If an app starts with capture
disabled and configuration is later changed to `True` without reinitialization,
this returns `True` while listeners remain detached, allowing restore to mutate
the live entity without creating a version. Tie this check to the
listener-registration state, or prevent runtime configuration changes from
enabling restores. [stale reference]
<details>
<summary><b>Severity Level:</b> Critical 🚨</summary>
```mdx
- ❌ Restore can perform destructive, untracked entity mutations.
- ❌ Chart, dashboard, and dataset restore history loses append-only
guarantees.
- ⚠️ Runtime configuration changes can bypass the documented kill-switch
behavior.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=9607104ee8a94f7d99a5587799fc3b19&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=9607104ee8a94f7d99a5587799fc3b19&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/versioning/utils.py
**Line:** 48:48
**Comment:**
*Stale Reference: The gate reads the mutable Flask configuration on
every request, but Continuum's write listeners are attached or detached only by
`init_versioning()` during initialization. If an app starts with capture
disabled and configuration is later changed to `True` without reinitialization,
this returns `True` while listeners remain detached, allowing restore to mutate
the live entity without creating a version. Tie this check to the
listener-registration state, or prevent runtime configuration changes from
enabling restores.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42469&comment_hash=eb08543a39c6a610ec60bc2eb901177f58a7067b0f9b52a649568a06edfc3605&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42469&comment_hash=eb08543a39c6a610ec60bc2eb901177f58a7067b0f9b52a649568a06edfc3605&reaction=dislike'>👎</a>
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]