codeant-ai-for-open-source[bot] commented on code in PR #41096:
URL: https://github.com/apache/superset/pull/41096#discussion_r3417349466
##########
superset/commands/report/execute.py:
##########
@@ -1170,6 +1169,21 @@ def run(self) -> None:
)
user = security_manager.find_user(username)
+ with override_user(user):
+ # Pre-commit any permalink rows before the state machine's
+ # @transaction() opens. When called inside a transaction,
+ # CreateDashboardPermalinkCommand only flushes (not commits),
+ # leaving the row invisible to Playwright's separate DB
+ # connection. Running get_dashboard_urls() here — outside any
+ # transaction — lets the command commit normally. The state
+ # machine's inner call to get_dashboard_urls() hits get_entry()
+ # for the same deterministic UUID and returns the
+ # already-committed row without a second INSERT.
+ if self._model.dashboard_id:
+ BaseReportState(
+ self._model, self._scheduled_dttm, self._execution_id
+ ).get_dashboard_urls()
Review Comment:
**🟠 Architect Review — HIGH**
Permalink prewarm now calls BaseReportState(...).get_dashboard_urls() before
ReportScheduleStateMachine.run(), so if get_dashboard_urls (and thus
CreateDashboardPermalinkCommand.run) raises—for example due to a deleted
dashboard, access denial, or key-value write failure—the exception aborts
AsyncExecuteReportScheduleCommand.run() before the state machine runs, meaning
last_state and execution logs are not updated and owner error notifications are
not sent, unlike the existing in-state-machine call where such failures are
caught and logged.
**Suggestion:** Keep the pre-commit permalink prewarm, but wrap it in error
handling that routes failures through the same report-state transition/logging
path as send() (or explicitly sets last_state=ERROR and logs/sends owner
notifications) so prewarm failures retain the existing recorded-failure
semantics instead of only surfacing as a task-level exception.
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=de6a7c1a406340ed9aa9345cba88991b&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=de6a7c1a406340ed9aa9345cba88991b&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 an **Architect / Logical Review** comment left during a code review.
These reviews are first-class, important findings — not optional suggestions.
Do NOT dismiss this as a 'big architectural change' just because the title says
architect review; most of these can be resolved with a small, localized fix
once the intent is understood.
**Path:** superset/commands/report/execute.py
**Line:** 1172:1185
**Comment:**
*HIGH: Permalink prewarm now calls
BaseReportState(...).get_dashboard_urls() before
ReportScheduleStateMachine.run(), so if get_dashboard_urls (and thus
CreateDashboardPermalinkCommand.run) raises—for example due to a deleted
dashboard, access denial, or key-value write failure—the exception aborts
AsyncExecuteReportScheduleCommand.run() before the state machine runs, meaning
last_state and execution logs are not updated and owner error notifications are
not sent, unlike the existing in-state-machine call where such failures are
caught and logged.
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.
If a suggested approach is provided above, use it as the authoritative
instruction. If no explicit code suggestion is given, you MUST still draft and
apply your own minimal, localized fix — do not punt back with 'no suggestion
provided, review manually'. Keep the change as small as possible: add a guard
clause, gate on a loading state, reorder an await, wrap in a conditional, etc.
Do not refactor surrounding code or expand scope beyond the finding.
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>
--
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]