{"record":{"id":"a6d2d3d12b3dbbbf","repo":"HKUDS/DeepTutor","slug":"not-authenticated","errorCode":null,"errorMessage":"Not authenticated","messagePattern":"Not authenticated","errorType":"http","errorClass":"HTTPException","httpStatus":401,"severity":"error","filePath":"deeptutor/api/routers/auth.py","lineNumber":269,"sourceCode":"\n    Returns the authenticated TokenPayload, or None if auth is disabled.\n    Raises HTTP 401 if auth is enabled but the token is missing or invalid.\n\n    Declared ``async def`` so the ``set_current_user`` call runs in the same\n    asyncio context as the endpoint. A sync dependency is dispatched via\n    ``anyio.to_thread.run_sync``, which executes the function in a worker\n    thread under a *copy* of the request context; any ``ContextVar.set``\n    inside that thread is discarded when the thread returns, leaving the\n    endpoint to read the unset default. That regression was the root cause\n    of #481.\n    \"\"\"\n    if not AUTH_ENABLED:\n        _install_current_user(None)\n        return None\n\n    token = _extract_token(authorization, dt_token)\n    if not token:\n        raise HTTPException(\n            status_code=status.HTTP_401_UNAUTHORIZED,\n            detail=\"Not authenticated\",\n            headers={\"WWW-Authenticate\": \"Bearer\"},\n        )\n\n    payload = decode_token(token)\n    if not payload:\n        raise HTTPException(\n            status_code=status.HTTP_401_UNAUTHORIZED,\n            detail=\"Invalid or expired token\",\n            headers={\"WWW-Authenticate\": \"Bearer\"},\n        )\n\n    _install_current_user(payload)\n    return payload\n\n\nclass _WsAuthFailed:","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/auth.py#L251-L287","documentation":"Error \"Not authenticated\" thrown in HKUDS/DeepTutor.","triggerScenarios":"Thrown at deeptutor/api/routers/auth.py:269 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}