lfnovo/open-notebook · error · HTTPException
Error creating model: {str(e)}
Error message
Error creating model: {str(e)} What it means
Generic 500 from POST /api/v1/models when model creation fails with an unexpected exception. InvalidInputError is mapped to 400 and OpenNotebookError is re-raised; anything else (DB failure, constructor error in Model) lands here.
Source
Thrown at api/routers/models.py:259
return ModelResponse(
id=new_model.id or "",
name=new_model.name,
provider=new_model.provider,
type=new_model.type,
credential=new_model.credential,
created=str(new_model.created),
updated=str(new_model.updated),
)
except HTTPException:
raise
except InvalidInputError as e:
raise HTTPException(status_code=400, detail=str(e))
except OpenNotebookError:
raise
except Exception as e:
logger.error(f"Error creating model: {str(e)}")
raise HTTPException(status_code=500, detail=f"Error creating model: {str(e)}")
@router.delete("/models/{model_id}")
async def delete_model(model_id: str):
"""Delete a model configuration."""
try:
model = await Model.get(model_id)
await model.delete()
return {"message": "Model deleted successfully"}
except HTTPException:
raise
except NotFoundError:
raise HTTPException(status_code=404, detail="Model not found")
except OpenNotebookError:
raise
except Exception as e:View on GitHub (pinned to a7de90d38a)
Solutions
- Read the API log line 'Error creating model: ...' for the root cause
- Verify DB connectivity and retry
- Check that all ModelCreate fields match expected types/shapes
- If caused by [82]'s race (duplicate created between check and insert), handle the unique-constraint error explicitly
Defensive patterns
Strategy: retry
Validate before calling
await assertDbHealthy(); // GET /api/v1/health before create
Try / catch
try { await api.createModel(data); } catch (e) { if (e.status === 500) { log(e.detail); await retryOnce(); } else throw e; } Prevention
- Verify DB connectivity before write operations
- Validate payload shape client-side
- Check logs for the embedded root-cause message
When it happens
Trigger: POST /models with an otherwise-valid body while SurrealDB is down or the Model constructor throws (e.g. malformed provider config object).
Common situations: DB connection dropped mid-request, missing required fields that bypass Pydantic validation, or unexpected type in model_data.
Related errors
- Error fetching models: {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/b1e5538289072e07.
Report an issue: GitHub.