codeant-ai-for-open-source[bot] commented on code in PR #45551:
URL: https://github.com/apache/superset/pull/45551#discussion_r4342873593
##########
superset/commands/dashboard/restore_version.py:
##########
@@ -43,3 +53,35 @@ class
RestoreDashboardVersionCommand(BaseRestoreVersionCommand):
not_found_exc = DashboardNotFoundError
forbidden_exc = DashboardForbiddenError
failed_exc = DashboardUpdateFailedError
+
+ def run(self) -> RestoreResult:
+ """Restore, confirming a reported chart-purge race before surfacing it.
+
+ The transaction has rolled back by the time the race reaches here,
+ so a fresh read sees the purge's commit. Only when one of the charts
+ whose membership the restore was changing is really gone is the
+ retryable :class:`ChartPurgedDuringRestoreError` raised. Otherwise,
+ or when the confirming read itself fails, the restore fails the
+ ordinary way.
+ """
+ try:
+ return super().run()
+ except ChartPurgedDuringRestoreError as ex:
+ slices: sa.Table = Slice.__table__
+ try:
+ remaining: set[int] = set(
+ db.session.execute(
+
sa.select(slices.c.id).where(slices.c.id.in_(ex.chart_ids))
Review Comment:
**Suggestion:** If a chart id is reused after purge, this treats the
replacement chart as the original, returning 422 instead of the retryable 409.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Rarely` ยท ๐ท๏ธ `Incorrect condition
logic`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=be4a2c702062408f9cae27919f65d94c&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=be4a2c702062408f9cae27919f65d94c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/commands/dashboard/restore_version.py
**Line:** 74:74
**Comment:**
*Incorrect Condition Logic: If a chart id is reused after purge, this
treats the replacement chart as the original, returning 422 instead of the
retryable 409.
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%2F45551&comment_hash=c6bca6e3b4d1ef6307bd9f03100044cfc4be014a91bd182a790fb1347647a3a0&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F45551&comment_hash=c6bca6e3b4d1ef6307bd9f03100044cfc4be014a91bd182a790fb1347647a3a0&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]