odysseus-dev/odysseus · error · HTTPException

Session manager not available

Error message

Session manager not available

What it means

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.

Source

Thrown at routes/webhook/webhook_routes.py:303

            # URLs are not subject to extra local/LAN blocking beyond existing provider logic.
            direct_base_url = body.base_url.strip().rstrip("/") if body.base_url else None
            if direct_base_url:
                try:
                    base_url = validate_public_http_url(direct_base_url)
                except ValueError as e:
                    detail = str(e).replace("URL", "base_url", 1)
                    raise HTTPException(400, detail)
            else:
                base_url = _resolve_base_url(model, body.provider)
            if not base_url:
                raise HTTPException(400,
                    "Could not auto-detect provider. Pass base_url (e.g. 'https://api.deepseek.com/v1') "
                    "or provider ('deepseek', 'openai', 'groq', etc.)")
            base_url = normalize_base(base_url)
            endpoint_url = build_chat_url(base_url)

            if not session_manager:
                raise HTTPException(500, "Session manager not available")

            sid = str(uuid.uuid4())
            sess = session_manager.create_session(
                session_id=sid, name="API Chat", endpoint_url=endpoint_url,
                model=model, owner=token_owner,
            )
            sess.headers = build_headers(api_key, base_url)
            session_manager.save_sessions()
            session_id = sid

        # --- Case 3: Fall back to first configured ModelEndpoint ---
        if not sess:
            db = SessionLocal()
            try:
                ep = _select_api_chat_fallback_endpoint(db, token_owner)
            finally:
                db.close()

View on GitHub (pinned to f9235ebbf1)

Solutions

  1. Check server startup logs for session-manager initialization errors
  2. Ensure the deployment config enables/initializes the session manager component
  3. If running the route in tests, inject or mock session_manager
Defensive patterns

Strategy: try-catch

Try / catch

if resp.status_code == 500 and detail == 'Session manager not available':
    alert_ops('server misconfiguration: session manager not initialized')  # not retryable client-side

Prevention

When it happens

Trigger: 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.

Common situations: Minimal deployments that disabled session persistence; unit tests importing the router standalone; startup ordering bugs where routes register before the manager.

Related errors


AI-assisted analysis of odysseus-dev/odysseus@f9235ebbf1 (2026-08-14). Data as JSON: /api/errors/8c6e2f1471dc2888. Report an issue: GitHub.