{"record":{"id":"d974cb8083281062","repo":"langchain-ai/langgraph","slug":"no-authenticated-user-available-in-access-context","errorCode":null,"errorMessage":"No authenticated user available in access_context='{self.access_context}'. Ensure custom auth is configured for the server.","messagePattern":"No authenticated user available in access_context='(.+?)'\\. Ensure custom auth is configured for the server\\.","errorType":"exception","errorClass":"PermissionError","httpStatus":null,"severity":"error","filePath":"libs/sdk-py/langgraph_sdk/runtime.py","lineNumber":141,"sourceCode":"        ```\n        \"\"\"\n        if isinstance(self, _ExecutionRuntime):\n            return self\n        return None\n\n    def ensure_user(self) -> BaseUser:\n        \"\"\"Return the authenticated user, or raise if not available.\n\n        When custom auth is configured, `user` is set for all access contexts\n        (the factory is only called from HTTP handlers where the auth\n        middleware has already run). This method raises only when no custom\n        auth is configured.\n\n        Raises:\n            PermissionError: If no user is authenticated.\n        \"\"\"\n        if self.user is None:\n            raise PermissionError(\n                f\"No authenticated user available in access_context='{self.access_context}'. \"\n                \"Ensure custom auth is configured for the server.\"\n            )\n        return self.user\n\n\n@dataclass(kw_only=True, slots=True, frozen=True)\nclass _ExecutionRuntime(_ServerRuntimeBase[ContextT], Generic[ContextT]):\n    \"\"\"Runtime for `threads.create_run` — the graph will be fully executed.\n\n    Access this via `.execution_runtime` on `ServerRuntime`. Do not\n    construct directly.\n\n    !!! warning \"Beta\"\n        This API is in beta and may change in future releases.\n    \"\"\"\n\n    context: ContextT = field(default=None)  # ty: ignore[invalid-assignment]","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/langchain-ai/langgraph/blob/38031739e551638e373fb553453256c23feeb41f/libs/sdk-py/langgraph_sdk/runtime.py#L123-L159","documentation":"PermissionError from runtime.ensure_user(): the current access context carries no authenticated user. With custom auth configured the auth middleware always populates runtime.user, so seeing this means the code path (e.g. a background task or a server without custom auth) ran where no user was authenticated.","triggerScenarios":"Thrown at libs/sdk-py/langgraph_sdk/runtime.py:141 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Configure custom auth on the LangGraph Server so the auth middleware populates the user","Check runtime.user for None before calling ensure_user() when running in contexts that may lack a user","Use runtime.user directly and handle the None case explicitly"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"38031739e551638e373fb553453256c23feeb41f","analyzedAt":"2026-08-26T18:02:49.312Z","contentChangedAt":"2026-08-26T18:02:49.312Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}