codeant-ai-for-open-source[bot] commented on code in PR #42836:
URL: https://github.com/apache/superset/pull/42836#discussion_r3728179622
##########
superset/views/dashboard/views.py:
##########
@@ -95,6 +95,9 @@ def new(self) -> FlaskResponse:
)
db.session.add(new_dashboard)
db.session.commit() # pylint: disable=consider-using-transaction
+ if after_create := current_app.config.get("AFTER_ASSET_CREATE"):
+ after_create(new_dashboard, "dashboard")
+ db.session.commit()
Review Comment:
**Suggestion:** The dashboard is committed before `AFTER_ASSET_CREATE` runs.
If the hook raises an exception, the request fails but the dashboard remains
permanently persisted, so the creation is not atomic and cannot be rolled back.
Invoke the hook before the transaction's commit, or explicitly roll back and
remove the dashboard when the hook fails. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Dashboard creation requests fail when configured hooks raise exceptions.
- ⚠️ Failed requests leave orphaned untitled dashboards persisted.
- ⚠️ Downstream integrations can make UI creation appear unsuccessful.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=e906ded8d56d447db8403bf523a90e24&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=e906ded8d56d447db8403bf523a90e24&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/views/dashboard/views.py
**Line:** 98:100
**Comment:**
*Logic Error: The dashboard is committed before `AFTER_ASSET_CREATE`
runs. If the hook raises an exception, the request fails but the dashboard
remains permanently persisted, so the creation is not atomic and cannot be
rolled back. Invoke the hook before the transaction's commit, or explicitly
roll back and remove the dashboard when the hook fails.
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%2F42836&comment_hash=cd7d19ceff0039bac5e28f2d4e9c0d3c4b89ce348ba3549404a60f2ccc28fb3c&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42836&comment_hash=cd7d19ceff0039bac5e28f2d4e9c0d3c4b89ce348ba3549404a60f2ccc28fb3c&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]