You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "alexandrusoare (via GitHub)" <gi...@apache.org> on 2026/08/06 10:50:45 UTC
[PR] feat(hooks): add configurable post-creation hook for dashboards [superset]
alexandrusoare opened a new pull request, #42836:
URL: https://github.com/apache/superset/pull/42836
### SUMMARY
Adds an `AFTER_ASSET_CREATE` config callback that fires after a new dashboard is persisted. This allows downstream integrations (e.g. auto-categorization, audit logging, notification triggers) to react to asset creation without modifying core views. The hook receives the model instance and the asset type string ("dashboard")
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
<!--- Skip this if not applicable -->
### TESTING INSTRUCTIONS
<!--- Required! What steps can be taken to manually verify the changes? -->
### 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] feat(hooks): add configurable post-creation hook for dashboards [superset]
Posted by "alexandrusoare (via GitHub)" <gi...@apache.org>.
alexandrusoare closed pull request #42836: feat(hooks): add configurable post-creation hook for dashboards
URL: https://github.com/apache/superset/pull/42836
--
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] feat(hooks): add configurable post-creation hook for dashboards [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #42836:
URL: https://github.com/apache/superset/pull/42836#issuecomment-5203846754
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/42836?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 `25.00000%` with `3 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 56.18%. Comparing base ([`bbd7ac7`](https://app.codecov.io/gh/apache/superset/commit/bbd7ac727890d53c389590d0c6af6b4a1bc45bdd?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`1f992d7`](https://app.codecov.io/gh/apache/superset/commit/1f992d72283cbbd0a87ea80db9b644864c8fa107?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 3 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/42836?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/views/dashboard/views.py](https://app.codecov.io/gh/apache/superset/pull/42836?src=pr&el=tree&filepath=superset%2Fviews%2Fdashboard%2Fviews.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvdmlld3MvZGFzaGJvYXJkL3ZpZXdzLnB5) | 25.00% | [3 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/42836?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #42836 +/- ##
==========================================
- Coverage 65.73% 56.18% -9.55%
==========================================
Files 2843 2843
Lines 162653 162656 +3
Branches 37239 37240 +1
==========================================
- Hits 106914 91387 -15527
- Misses 53647 70426 +16779
+ Partials 2092 843 -1249
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/42836/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/42836/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `37.95% <25.00%> (-0.01%)` | :arrow_down: |
| [mysql](https://app.codecov.io/gh/apache/superset/pull/42836/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/42836/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/42836/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.86% <25.00%> (-0.01%)` | :arrow_down: |
| [python](https://app.codecov.io/gh/apache/superset/pull/42836/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.92% <25.00%> (-19.29%)` | :arrow_down: |
| [sqlite](https://app.codecov.io/gh/apache/superset/pull/42836/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/42836/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/42836?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] feat(hooks): add configurable post-creation hook for dashboards [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42836:
URL: https://github.com/apache/superset/pull/42836#issuecomment-5203716913
<!-- Bito Reply -->
The flagged issue is correct. Committing the transaction before executing the hook means that if the hook fails, the dashboard remains in the database, violating atomicity. To resolve this, you should move the hook execution before the initial commit or wrap the operations in a try-except block to roll back the session if the hook fails.
Here is a concise fix:
```python
db.session.add(new_dashboard)
try:
db.session.commit()
if after_create := current_app.config.get("AFTER_ASSET_CREATE"):
after_create(new_dashboard, "dashboard")
db.session.commit()
except Exception:
db.session.rollback()
raise
```
There are no other comments in this PR. Would you like me to review any other parts of the code?
**superset/views/dashboard/views.py**
```
db.session.add(new_dashboard)
try:
db.session.commit()
if after_create := current_app.config.get("AFTER_ASSET_CREATE"):
after_create(new_dashboard, "dashboard")
db.session.commit()
except Exception:
db.session.rollback()
raise
```
--
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] feat(hooks): add configurable post-creation hook for dashboards [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42836:
URL: https://github.com/apache/superset/pull/42836#issuecomment-5205656335
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 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] feat(hooks): add configurable post-creation hook for dashboards [superset]
Posted by "alexandrusoare (via GitHub)" <gi...@apache.org>.
alexandrusoare closed pull request #42836: feat(hooks): add configurable post-creation hook for dashboards
URL: https://github.com/apache/superset/pull/42836
--
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] feat(hooks): add configurable post-creation hook for dashboards [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
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: 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] feat(hooks): add configurable post-creation hook for dashboards [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42836:
URL: https://github.com/apache/superset/pull/42836#issuecomment-5203671036
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