{"record":{"id":"bc36404c7d1d912e","repo":"apache/superset","slug":"token-not-preset","errorCode":null,"errorMessage":"Token not preset","messagePattern":"Token not preset","errorType":"http","errorClass":"AsyncQueryTokenException","httpStatus":401,"severity":"error","filePath":"superset/async_events/async_query_manager.py","lineNumber":273,"sourceCode":"                \"rev\": token.get(\"rev\"),\n            },\n            sort_keys=True,\n        ).encode(\"utf-8\")\n        digest = hmac.new(\n            self._jwt_secret.encode(\"utf-8\"), message, hashlib.sha256\n        ).hexdigest()\n        return f\"guest-{digest}\"\n\n    def parse_channel_id_from_request(self, req: Request) -> str:\n        # pylint: disable=import-outside-toplevel\n        from superset import security_manager\n\n        if guest_user := security_manager.get_current_guest_user_if_guest():\n            return self.get_guest_user_channel_id(guest_user)\n\n        token = req.cookies.get(self._jwt_cookie_name)\n        if not token:\n            raise AsyncQueryTokenException(\"Token not preset\")\n\n        try:\n            return jwt.decode(token, self._jwt_secret, algorithms=[\"HS256\"])[\"channel\"]\n        except Exception as ex:\n            logger.warning(\"Parse jwt failed\", exc_info=True)\n            raise AsyncQueryTokenException(\"Failed to parse token\") from ex\n\n    def init_job(self, channel_id: str, user_id: Optional[int]) -> dict[str, Any]:\n        job_id = str(uuid.uuid4())\n        self._register_cancellable_job(job_id, channel_id, user_id)\n        return build_job_metadata(\n            channel_id, job_id, user_id, status=self.STATUS_PENDING\n        )\n\n    def _job_registry_key(self, job_id: str) -> str:\n        return f\"{self._stream_prefix}{self._JOB_REGISTRY_PREFIX}{job_id}\"\n\n    def _register_cancellable_job(","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/async_events/async_query_manager.py#L255-L291","documentation":"AsyncQueryTokenException('Token not preset') ('preset' is a typo for 'present' in the source) is raised by parse_channel_id_from_request() when the async-queries JWT cookie named by GLOBAL_ASYNC_QUERIES_JWT_COOKIE_NAME is absent from the request. With GAQ enabled, every chart-data request must carry this cookie so Superset knows which Redis stream channel to publish events to; guest users bypass it via a derived channel id.","triggerScenarios":"Calling the chart data / async endpoints with curl, requests, or a script (no cookie jar) while GLOBAL_ASYNC_QUERIES is enabled; browser sessions where the cookie was never set because the user authenticated before the feature was turned on, the cookie domain/path config is wrong, or cookies are blocked.","commonSituations":"See trigger scenarios.","solutions":["For API clients: first request a session (login) the same way the UI does so the async token cookie is issued, then replay it with the cookie jar on subsequent requests.","For browsers: log out and back in (or clear cookies) after enabling GLOBAL_ASYNC_QUERIES so the JWT cookie gets set; verify GLOBAL_ASYNC_QUERIES_JWT_COOKIE_DOMAIN/secure/samesite settings match your deployment (HTTPS vs HTTP).","Confirm you are not stripping cookies at a proxy/load balancer."],"exampleFix":"# before (python client)\nrequests.post(url, json=payload)  # no cookies -> Token not preset\n\n# after\nimport requests\ns = requests.Session()\ns.auth = (user, pwd)  # or s.post(login_url, ...)\ns.get(\"http://superset:8088/api/v1/chart/data\")  # establishes cookies\nresp = s.post(\"http://superset:8088/api/v1/chart/data\", json=payload)","handlingStrategy":"try-catch","validationCode":"cookie_name = app.config[\"GLOBAL_ASYNC_QUERIES_JWT_COOKIE_NAME\"]\nif not request.cookies.get(cookie_name) and not current_user.is_guest:\n    # re-establish session: hit the app once so the token cookie is issued\n    return reauthenticate()","typeGuard":null,"tryCatchPattern":"from superset.async_events.async_query_manager import AsyncQueryTokenException\ntry:\n    channel_id = manager.parse_channel_id_from_request(request)\nexcept AsyncQueryTokenException:\n    # 401: client must (re)login to obtain the async token cookie\n    return response_401()","preventionTips":["Use a cookie-preserving session in API clients; never call chart-data endpoints cookie-less with GAQ on.","After enabling GAQ or changing its cookie settings, force users to re-authenticate."],"tags":["async-queries","authentication","cookies","jwt","http"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}