lfnovo/open-notebook · error · HTTPException
Error fetching models: {str(e)}
Error message
Error fetching models: {str(e)} What it means
Generic 500 raised by GET /api/v1/models when listing model configs fails unexpectedly. It is the catch-all branch after HTTPException and OpenNotebookError were re-raised, so any non-domain exception (DB down, import error) surfaces here with the underlying message embedded.
Source
Thrown at api/routers/models.py:202
return [
ModelResponse(
id=model.id,
name=model.name,
provider=model.provider,
type=model.type,
credential=model.credential,
created=str(model.created),
updated=str(model.updated),
)
for model in models
]
except HTTPException:
raise
except OpenNotebookError:
raise
except Exception as e:
logger.error(f"Error fetching models: {str(e)}")
raise HTTPException(status_code=500, detail=f"Error fetching models: {str(e)}")
@router.post("/models", response_model=ModelResponse)
async def create_model(model_data: ModelCreate):
"""Create a new model configuration."""
try:
# Validate model type
valid_types = ["language", "embedding", "text_to_speech", "speech_to_text"]
if model_data.type not in valid_types:
raise HTTPException(
status_code=400,
detail=f"Invalid model type. Must be one of: {valid_types}",
)
# Check for duplicate model name under the same provider and type (case-insensitive)
from open_notebook.database.repository import repo_query
existing = await repo_query(View on GitHub (pinned to a7de90d38a)
Solutions
- Check the API logs for the logged 'Error fetching models' line to see the real exception
- Verify SurrealDB is running and reachable (make status / make database)
- Verify OPEN_NOTEBOOK_DB settings and restart make api
- If the inner exception points to a provider SDK, fix the provider configuration/env keys
Defensive patterns
Strategy: try-catch
Validate before calling
const health = await fetch('/api/v1/health').then(r=>r.ok); // or check /models with a tiny HEAD-ish GET before heavy listing
if (!health) throw new Error('API/DB unavailable'); Try / catch
try { const models = await api.getModels(); } catch (e) { if (e.status === 500) showFatal('Model listing failed: ' + e.detail); else throw e; } Prevention
- Keep SurrealDB running (make database) before the API
- Monitor API logs for 'Error fetching models'
- Use health checks before bulk UI loads
When it happens
Trigger: Calling GET /models when SurrealDB is unreachable, when the Model class query fails, or when provider introspection throws a non-OpenNotebookError exception.
Common situations: SurrealDB not started (make database), wrong DB credentials, or a model provider SDK raising an unexpected exception during listing.
Related errors
- Error creating model: {str(e)}
- Failed to list credentials
- Failed to update credential
- Failed to fetch episode profiles
- Failed to fetch episode profile
AI-assisted analysis of lfnovo/open-notebook@a7de90d38a (2026-08-27).
Data as JSON: /api/errors/204c0940dd6e5973.
Report an issue: GitHub.