eschutho opened a new pull request, #41096:
URL: https://github.com/apache/superset/pull/41096

   ## Problem
   
   Dashboard report schedules that target specific tabs use 
`CreateDashboardPermalinkCommand` to generate a `/dashboard/p/<key>/` URL for 
Playwright to navigate to. The command is invoked deep inside 
`AsyncExecuteReportScheduleCommand.run()`, which is decorated with 
`@transaction()`. The `@transaction()` nesting guard (`g.in_transaction`) 
detects this and skips `db.session.commit()`, leaving the permalink row only 
flushed — visible inside the current SQLAlchemy session but not committed to 
the database.
   
   Playwright runs in a separate process with its own DB connection. When it 
navigates to `/dashboard/p/<key>/`, Flask's `dashboard_permalink` view can't 
find the row and returns a JSON 404. The page never renders `<body 
class="standalone">` (server-rendered in `spa.html`, not React-added), so 
Playwright waits the full `SCREENSHOT_PLAYWRIGHT_DEFAULT_TIMEOUT` (600 s) 
before timing out.
   
   ## Fix
   
   Remove `@transaction()` from `AsyncExecuteReportScheduleCommand.run()` and 
call `get_dashboard_urls()` on a temporary `BaseReportState` instance *before* 
the state machine starts. Running outside any transaction, 
`CreateDashboardPermalinkCommand` can commit normally through its own 
`@transaction()`. The state machine's subsequent `get_dashboard_urls()` call 
finds the already-committed row via `get_entry()` (same deterministic UUID) and 
returns it without a second INSERT.
   
   `ReportScheduleStateMachine.run()` retains its own `@transaction()` and 
becomes the sole outermost transaction owner — behaviour identical to the 
status quo except that permalink creation now happens before the transaction 
window opens.
   
   ## Changes
   
   Single file, `superset/commands/report/execute.py`:
   - Remove `@transaction()` from `AsyncExecuteReportScheduleCommand.run()`
   - Add a `get_dashboard_urls()` pre-warm call (guarded by `dashboard_id`) 
before the state machine
   
   No changes to the state machine, state classes, `_get_screenshots()`, 
`scheduler.py`, or any test files.
   
   ## Testing
   
   - Tab-specific dashboard reports now commit their permalink before 
Playwright navigates, eliminating the 600 s timeout.
   - Dashboard reports without tab state skip the pre-warm (no `dashboard_id` 
guard mismatch — wait, `dashboard_id` is set for all dashboard reports; only 
tab-specific ones produce a permalink — the plain-URL path in 
`get_dashboard_urls()` is a no-op read).
   - Chart reports are unaffected (`self._model.dashboard_id` is `None`).
   - Alert reports are unaffected (they never reach `_get_screenshots()`'s 
dashboard path).
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
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]

Reply via email to