lfnovo/open-notebook · error · HTTPException
Failed to check environment status
Error message
Failed to check environment status
What it means
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.
Source
Thrown at api/routers/credentials.py:107
except OpenNotebookError:
raise
except Exception as e:
logger.error(f"Error fetching status: {e}")
raise HTTPException(status_code=500, detail="Failed to fetch credential status")
@router.get("/env-status")
async def get_env_status():
"""Check what's configured via environment variables."""
try:
return await svc_get_env_status()
except HTTPException:
raise
except OpenNotebookError:
raise
except Exception as e:
logger.error(f"Error checking env status: {e}")
raise HTTPException(status_code=500, detail="Failed to check environment status")
# =============================================================================
# CRUD endpoints
# =============================================================================
@router.get("", response_model=List[CredentialResponse])
async def list_credentials(
provider: Optional[str] = Query(None, description="Filter by provider"),
):
"""List all credentials, optionally filtered by provider."""
try:
if provider:
credentials = await Credential.get_by_provider(provider)
else:
credentials = await Credential.get_all(order_by="provider, created")
View on GitHub (pinned to a7de90d38a)
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
Defensive patterns
Strategy: try-catch
Try / catch
try {
const status = await api.getEnvStatus();
} catch (e) {
// 500 here almost always means infra: surface a 'check your database connection' message
if (e.status === 500) return { degraded: true, message: 'Environment status unavailable — check DB and API logs' };
throw e;
} Prevention
- Monitor SurrealDB availability before rendering status panels
- Keep OPEN_NOTEBOOK_ENCRYPTION_KEY stable across restarts
- Treat env-status 500s as degraded-mode, not fatal
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to list credentials
- Failed to list credentials for provider
- Failed to create credential
- Failed to update credential
- Failed to delete credential
AI-assisted analysis of lfnovo/open-notebook@a7de90d38a (2026-08-27).
Data as JSON: /api/errors/90a479a6ce8c57ce.
Report an issue: GitHub.