{"record":{"id":"88a0daf8e22bb596","repo":"odysseus-dev/odysseus","slug":"not-authenticated-88a0da","errorCode":null,"errorMessage":"Not authenticated","messagePattern":"Not authenticated","errorType":"http","errorClass":"HTTPException","httpStatus":401,"severity":"error","filePath":"routes/model_routes.py","lineNumber":1637,"sourceCode":"    def api_models(request: Request, refresh: bool = False, background: bool = False):\n        \"\"\"Get available models — per-user (caller sees only their endpoints +\n        legacy/shared null-owner rows). Cached per-user for 30s.\"\"\"\n        # Require auth; \"\" is the unconfigured single-user mode, treated as\n        # \"see everything\" by _fetch_models.\n        try:\n            if getattr(request.state, \"api_token\", False):\n                scopes = set(getattr(request.state, \"api_token_scopes\", []) or [])\n                if \"chat\" not in scopes:\n                    raise HTTPException(403, \"API token is not scoped for chat\")\n                if not getattr(request.state, \"api_token_owner\", None):\n                    raise HTTPException(403, \"API token has no owner\")\n            owner = effective_user(request) or \"\"\n\n            # Reject anonymous in configured deployments — no leaking the model\n            # list to unauthenticated callers.\n            auth_mgr = getattr(request.app.state, \"auth_manager\", None)\n            if not owner and not _auth_disabled() and auth_mgr is not None and getattr(auth_mgr, \"is_configured\", False):\n                raise HTTPException(401, \"Not authenticated\")\n        except HTTPException:\n            raise\n        except Exception as e:\n            logger.error(\"Auth gate error in GET /api/models, failing closed: %s\", e)\n            raise HTTPException(status_code=500, detail=\"Internal error\")\n        # Admins see every endpoint (they manage the global pool); regular\n        # users get the owner-scoped view.\n        _is_admin = False\n        try:\n            auth_mgr = getattr(request.app.state, \"auth_manager\", None)\n            if owner and auth_mgr is not None and getattr(auth_mgr, \"is_admin\", None):\n                _is_admin = bool(auth_mgr.is_admin(owner))\n        except Exception:\n            _is_admin = False\n        now = _time.time()\n        # Cache key includes the admin flag so a demotion / promotion doesn't\n        # serve the wrong scoped view from cache.\n        _cache_key = (owner, _is_admin)","sourceCodeStart":1619,"sourceCodeEnd":1655,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/routes/model_routes.py#L1619-L1655","documentation":"Error \"Not authenticated\" thrown in odysseus-dev/odysseus.","triggerScenarios":"Triggered when the corresponding server-side validation or runtime check at the recorded location rejects the request or operation and returns this error message to the caller.","commonSituations":"See trigger scenarios.","solutions":["Log in and retry the request.","Provide a valid session cookie or API token."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}