codeant-ai-for-open-source[bot] commented on code in PR #43340:
URL: https://github.com/apache/superset/pull/43340#discussion_r3816036088
##########
superset/tasks/export_dashboard_excel.py:
##########
@@ -451,26 +451,37 @@ def _handle_export_failure(
def export_dashboard_excel(
self: Any, # pylint: disable=unused-argument
dashboard_id: int,
- user_id: int,
+ user_id: int | None,
active_data_mask: dict[str, Any],
job_id: str,
mode: str = EXPORT_MODE_DATA,
+ guest_token: dict[str, Any] | None = None,
) -> None:
"""
Export a dashboard's charts to an ``.xlsx`` and record a download link.
:param dashboard_id: The dashboard to export
- :param user_id: The requesting user (the task runs with their permissions)
+ :param user_id: The requesting user (the task runs with their permissions),
+ or ``None`` for a guest/embedded requester
:param active_data_mask: Live dashboard filter state keyed by native
filter id
:param job_id: Correlation id, also the Celery task id and S3 object name
:param mode: ``"data"`` streams every chart's tabular result; ``"images"``
embeds non-table charts as rendered images and keeps tables tabular
+ :param guest_token: The guest token payload when the requester is an
+ embedded guest; the guest user is reconstructed from it so the export
+ runs under the token's RLS rules and resource claims, never under an
+ elevated identity
"""
# pylint: disable=import-outside-toplevel
from superset.models.dashboard import Dashboard
requested_at = datetime.now(tz=timezone.utc)
- user = security_manager.get_user_by_id(user_id)
+ if user_id is not None:
+ user = security_manager.get_user_by_id(user_id)
+ elif guest_token:
+ user = security_manager.get_guest_user_from_token(guest_token)
+ else:
+ user = None
Review Comment:
**Suggestion:** The guest reconstruction runs before the `try`/`finally`
that releases the distributed lock. If `get_guest_user_from_token` raises—for
example because the guest role lookup or metadata access fails—the task exits
without releasing the lock acquired by the API, leaving every guest export for
that dashboard blocked until the TTL expires. Move user reconstruction inside
the protected block or explicitly release the lock on this failure path.
[missing cleanup]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Guest exports remain blocked until lock TTL expiry.
- ⚠️ All guests share the affected dashboard's slot-0 lock.
- ⚠️ Failure status is not recorded for this path.
```
</details>
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/tasks/export_dashboard_excel.py
**Line:** 479:484
**Comment:**
*Missing Cleanup: The guest reconstruction runs before the
`try`/`finally` that releases the distributed lock. If
`get_guest_user_from_token` raises—for example because the guest role lookup or
metadata access fails—the task exits without releasing the lock acquired by the
API, leaving every guest export for that dashboard blocked until the TTL
expires. Move user reconstruction inside the protected block or explicitly
release the lock on this failure path.
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%2F43340&comment_hash=05f614621b5eb38aa7d628ab7971523edf5769a3049b2642cd07966b80450ca2&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43340&comment_hash=05f614621b5eb38aa7d628ab7971523edf5769a3049b2642cd07966b80450ca2&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]