[Embedding Dashboard] GLOBAL_ASYNC_QUERIES fails with 401 InvalidSubjectError for guest/embedded users
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- authentication, backend
Direzione di ricerca
Inizia da superset/async_events/async_query_manager.py: l'hook after_request in register_request_handlers() costruisce il JWT del canale con sub impostato a None quando get_user_id() è None, e parse_channel_id_from_request() lo decodifica. Per riprodurre, invia una richiesta POST /api/v1/chart/data non autenticata con GLOBAL_ASYNC_QUERIES abilitato e verifica se compare un 401. È completato quando le richieste ospite ricevono un token valido senza sub nullo e rispondono senza 401, mentre il comportamento esistente per le richieste autenticate resta invariato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug description
When EMBEDDED_SUPERSET and GLOBAL_ASYNC_QUERIES are both enabled, embedded dashboards fail to load chart data and native filters for guest users. Every POST /api/v1/chart/data request returns HTTP 401 with InvalidSubjectError: Subject must be a string.
Root Cause
In superset/async_events/async_query_manager.py:
In AsyncQueryManager.register_request_handlers() (after_request), sub is set to None when get_user_id() is None (which is always the case for embedded GuestUser / unauthenticated users):
sub = str(user_id) if user_id else None
token = jwt.encode(
{"channel": async_channel_id, "sub": sub},
self._jwt_secret,
algorithm="HS256",
)
- Encoding "sub": None produces "sub": null in the JWT payload.
- In AsyncQueryManager.parse_channel_id_from_request(), jwt.decode(...) raises jwt.exceptions.InvalidSubjectError: Subject must be a string (PyJWT enforces sub to be a string when present, per RFC 7519).
- AsyncQueryTokenException is raised, causing ChartDataRestApi to return HTTP 401.
How to Reproduce
- Enable both EMBEDDED_SUPERSET = True and GLOBAL_ASYNC_QUERIES = True in superset_config.py.
- Embed a dashboard using @superset-ui/embedded-sdk in an external app (without an active Superset user login session in the browser).
- Load the embedded dashboard.
Actual Behavior
- POST /api/v1/chart/data returns 401.
- Charts display Data error, native filters display Network error, and the embedded UI shows: "This session has encountered an interruption, and some controls may not work as intended...".
- Server log:
WARNING:superset.async_events.async_query_manager:Parse jwt failed
...
jwt.exceptions.InvalidSubjectError: Subject must be a string
Expected Behavior
Guest/embedded users should receive a valid async channel JWT and load chart data and native filters without 401 errors.
Suggested Fix
Omit "sub" from the JWT payload when user_id is None:
python
payload: dict[str, Any] = {"channel": async_channel_id}
if user_id is not None:
payload["sub"] = str(user_id)
token = jwt.encode(payload, self._jwt_secret, algorithm="HS256")
(Optionally also pass options={"verify_sub": False} in jwt.decode(...) for backwards compatibility with existing cookies.)
Screenshots/recordings
No response
Superset version
6.1.0
Python version
3.12
Node version
18 or greater
Browser
Chrome
Additional context
No response
Checklist
- I have searched Superset docs and Slack and didn't find a solution to my problem.
- I have searched the GitHub issue tracker and didn't find a similar bug report.
- I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
- Lingua principale
- Python
- Stelle
- 75.6k
- Fork
- 18.6k
- Merge medio
- 4g 2h
- PR unite (30g)
- 469
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/superset
-
SQL Lab: pasting text that matches no database into the "Data connection" select throws TypeErrorAperta#bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 2 giorni
-
🦾 ai-candidate
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
apache/superset#46238 · 3 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
Explore filter: multi-select value list with allowNewOptions stops accepting values and drops earlier onesForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta🦾 ai-candidate
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
apache/superset#46146 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
[Bug] Table chart applies Time grain to only the first temporal column (regression from 4.0.2)Forse già presa @PrakharAgarwal17 l’ha presa 24 giorni fa. Aperta#bug 🦾 ai-candidate
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
apache/superset#45964 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Stacked "Only Total" still includes the sort-only metric on time-comparison charts (follow-up to #42881)Forse già presa @waterWang l’ha presa 109 giorni fa. Apertaviz:charts:timeseries
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
apache/superset#43068 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di apache/superset
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
bug crash needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Community-Access/quill#2135 ·
I maintainer di solito rispondono entro 1 giorno
-
documentation good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
munendra07-tech/agent-crashtest#20 ·
I maintainer di solito rispondono entro 1 giorno
-
braveapi: time range filter is sent as time_range, which the Brave API ignores (needs freshness)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno
-
request_access
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100