{"record":{"id":"d73768595ee08d5d","repo":"HKUDS/DeepTutor","slug":"invalid-or-expired-token","errorCode":null,"errorMessage":"Invalid or expired token","messagePattern":"Invalid or expired token","errorType":"http","errorClass":"HTTPException","httpStatus":401,"severity":"error","filePath":"deeptutor/api/routers/auth.py","lineNumber":277,"sourceCode":"    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:\n    \"\"\"Sentinel: ws_require_auth failed and closed the WebSocket.\"\"\"\n\n\nws_auth_failed: _WsAuthFailed = _WsAuthFailed()\n\n\nasync def ws_require_auth(ws: WebSocket) -> _CtxToken | _WsAuthFailed:\n    \"\"\"Authenticate a WebSocket connection and set the user ContextVar.","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/auth.py#L259-L295","documentation":"Error \"Invalid or expired token\" thrown in HKUDS/DeepTutor.","triggerScenarios":"Thrown at deeptutor/api/routers/auth.py:277 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"}