{"record":{"id":"90a479a6ce8c57ce","repo":"lfnovo/open-notebook","slug":"failed-to-check-environment-status","errorCode":null,"errorMessage":"Failed to check environment status","messagePattern":"Failed to check environment status","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"api/routers/credentials.py","lineNumber":107,"sourceCode":"    except OpenNotebookError:\n        raise\n    except Exception as e:\n        logger.error(f\"Error fetching status: {e}\")\n        raise HTTPException(status_code=500, detail=\"Failed to fetch credential status\")\n\n\n@router.get(\"/env-status\")\nasync def get_env_status():\n    \"\"\"Check what's configured via environment variables.\"\"\"\n    try:\n        return await svc_get_env_status()\n    except HTTPException:\n        raise\n    except OpenNotebookError:\n        raise\n    except Exception as e:\n        logger.error(f\"Error checking env status: {e}\")\n        raise HTTPException(status_code=500, detail=\"Failed to check environment status\")\n\n\n# =============================================================================\n# CRUD endpoints\n# =============================================================================\n\n\n@router.get(\"\", response_model=List[CredentialResponse])\nasync def list_credentials(\n    provider: Optional[str] = Query(None, description=\"Filter by provider\"),\n):\n    \"\"\"List all credentials, optionally filtered by provider.\"\"\"\n    try:\n        if provider:\n            credentials = await Credential.get_by_provider(provider)\n        else:\n            credentials = await Credential.get_all(order_by=\"provider, created\")\n","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/lfnovo/open-notebook/blob/a7de90d38aaf18ee85fd661854d35c11e44613e2/api/routers/credentials.py#L89-L125","documentation":"Generic 500 raised by the GET /env-status endpoint when checking environment/credential status fails with an unexpected (non-HTTP, non-OpenNotebook) exception. It is a catch-all: any bug, DB connectivity issue, or malformed state in the status-check code path surfaces as this opaque message.","triggerScenarios":"Calling GET /api/env/status when SurrealDB is unreachable, when a credential record contains malformed/undecryptable data (e.g. OPEN_NOTEBOOK_ENCRYPTION_KEY changed), or when any unexpected exception escapes the status computation code.","commonSituations":"Database not started (make database skipped), rotated or missing encryption key making stored credential secrets undecryptable, or schema drift after an upgrade where old records lack expected fields.","solutions":["Check the API logs for the preceding 'Error checking env status: ...' line — it names the real exception","Verify SurrealDB is running (make status) and reachable on port 8000","Confirm OPEN_NOTEBOOK_ENCRYPTION_KEY matches the key used when credentials were stored","Re-run schema migrations by restarting the API (make api) and retry"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const status = await api.getEnvStatus();\n} catch (e) {\n  // 500 here almost always means infra: surface a 'check your database connection' message\n  if (e.status === 500) return { degraded: true, message: 'Environment status unavailable — check DB and API logs' };\n  throw e;\n}","preventionTips":["Monitor SurrealDB availability before rendering status panels","Keep OPEN_NOTEBOOK_ENCRYPTION_KEY stable across restarts","Treat env-status 500s as degraded-mode, not fatal"],"tags":["credentials","environment-status","http-500","open-notebook"],"backgroundTag":"http-500-fallback","analyzedSha":"a7de90d38aaf18ee85fd661854d35c11e44613e2","analyzedAt":"2026-08-27T02:39:58.166Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}