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

   ### SUMMARY
   
   Targets `fix/excel-export-guest-sessions-and-s3-link-expiry` (#43336), not 
`master` — it fixes a bug in that PR's guest path and is meant to merge into it 
so the guard removal and this fix travel together.
   
   #43336 removes the `isinstance(g.user, GuestUser)` → 400 guard so embedded 
guests can export, but `export_xlsx` still calls `g.user.id` (for the 
throttle-lock params and the Celery task's `user_id`). `GuestUser` extends 
`AnonymousUserMixin` and has no `id` attribute, so a guest POST crashes with 
`AttributeError` → 500 `{"message": "Fatal error"}` before the task is ever 
enqueued. Verified empirically on a staging deployment carrying #43336's 
changes: the embedded export button returned exactly that 500; with this fix 
applied the export goes through.
   
   The fix mirrors `_load_user_from_job_metadata` in 
`superset/tasks/async_queries.py`:
   - The endpoint passes `user_id=get_user_id()` (`None` for guests) plus 
`guest_token=getattr(g.user, "guest_token", None)`.
   - The task reconstructs the guest via 
`security_manager.get_guest_user_from_token(...)`, so the export runs under the 
token's RLS rules and resource claims — never under an elevated identity.
   - Guests share throttle-lock slot 0 per dashboard, acquired and released 
with the same key.
   
   ### TESTING INSTRUCTIONS
   
   - New unit test 
`test_guest_export_reconstructs_guest_user_and_shares_lock_slot_zero` covers 
the guest resolution, the skipped email, and the slot-0 lock release.
   - Manual: embed a dashboard, trigger Export Data to Excel as a guest — 
previously 500, now 202 + pollable download.
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: fixes the guest path of #43336
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_012HwFSVNUzsZ4xW6D8Y2n95


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