{"record":{"id":"8c6e2f1471dc2888","repo":"odysseus-dev/odysseus","slug":"session-manager-not-available","errorCode":null,"errorMessage":"Session manager not available","messagePattern":"Session manager not available","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"routes/webhook/webhook_routes.py","lineNumber":303,"sourceCode":"            # URLs are not subject to extra local/LAN blocking beyond existing provider logic.\n            direct_base_url = body.base_url.strip().rstrip(\"/\") if body.base_url else None\n            if direct_base_url:\n                try:\n                    base_url = validate_public_http_url(direct_base_url)\n                except ValueError as e:\n                    detail = str(e).replace(\"URL\", \"base_url\", 1)\n                    raise HTTPException(400, detail)\n            else:\n                base_url = _resolve_base_url(model, body.provider)\n            if not base_url:\n                raise HTTPException(400,\n                    \"Could not auto-detect provider. Pass base_url (e.g. 'https://api.deepseek.com/v1') \"\n                    \"or provider ('deepseek', 'openai', 'groq', etc.)\")\n            base_url = normalize_base(base_url)\n            endpoint_url = build_chat_url(base_url)\n\n            if not session_manager:\n                raise HTTPException(500, \"Session manager not available\")\n\n            sid = str(uuid.uuid4())\n            sess = session_manager.create_session(\n                session_id=sid, name=\"API Chat\", endpoint_url=endpoint_url,\n                model=model, owner=token_owner,\n            )\n            sess.headers = build_headers(api_key, base_url)\n            session_manager.save_sessions()\n            session_id = sid\n\n        # --- Case 3: Fall back to first configured ModelEndpoint ---\n        if not sess:\n            db = SessionLocal()\n            try:\n                ep = _select_api_chat_fallback_endpoint(db, token_owner)\n            finally:\n                db.close()\n","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/routes/webhook/webhook_routes.py#L285-L321","documentation":"HTTP 500 from POST /v1/chat Case 2: the global session_manager is None/unavailable when the route needs to create a transient session for the direct api_key call. This is a server-side wiring problem, not a caller input problem — the app booted without its session subsystem.","triggerScenarios":"Any POST /v1/chat with api_key (+ resolvable provider/base_url) while session_manager is None — e.g. disabled in config, failed initialization at startup, or a test harness that mounts the router without the manager.","commonSituations":"Minimal deployments that disabled session persistence; unit tests importing the router standalone; startup ordering bugs where routes register before the manager.","solutions":["Check server startup logs for session-manager initialization errors","Ensure the deployment config enables/initializes the session manager component","If running the route in tests, inject or mock session_manager"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if resp.status_code == 500 and detail == 'Session manager not available':\n    alert_ops('server misconfiguration: session manager not initialized')  # not retryable client-side","preventionTips":["Monitor startup logs for session-manager init failures before accepting traffic","Add a readiness check that fails when session_manager is None"],"tags":["server-error","session-manager","chat","http-500"],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}