lfnovo/open-notebook · error · HTTPException
Error deleting model: {str(e)}
Error message
Error deleting model: {str(e)} What it means
Catch-all 500 from DELETE /api/v1/models/{model_id} when deletion fails unexpectedly. HTTPException, NotFoundError, and OpenNotebookError are re-raised first; this branch catches anything else, typically a database error during model.delete().
Source
Thrown at api/routers/models.py:279
@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:
logger.error(f"Error deleting model {model_id}: {str(e)}")
raise HTTPException(status_code=500, detail=f"Error deleting model: {str(e)}")
@router.post("/models/{model_id}/test", response_model=ModelTestResponse)
async def test_model(model_id: str):
"""Test if a specific model is correctly configured and functional."""
try:
model = await Model.get(model_id)
if not model:
raise HTTPException(status_code=404, detail="Model not found")
except HTTPException:
raise
except OpenNotebookError:
raise
except Exception:
raise HTTPException(status_code=404, detail="Model not found")
try:
success, message = await test_individual_model(model)View on GitHub (pinned to a7de90d38a)
Solutions
- Check API logs for 'Error deleting model {id}'
- Unassign the model from defaults (update via PATCH defaults) before deleting
- Verify DB connectivity and retry
Defensive patterns
Strategy: try-catch
Validate before calling
const defaults = await api.getDefaultModels();
const inUse = Object.values(defaults).includes(modelId);
if (inUse) throw new Error('Reassign default before deleting'); Try / catch
try { await api.deleteModel(id); } catch (e) { if (e.status === 500) { checkLogs(); unassignDefaults(); await retry(); } } Prevention
- Unassign a model from defaults before deleting it
- Keep DB healthy
- Read the logged inner exception
When it happens
Trigger: DELETE /models/{id} while SurrealDB is unreachable, or when deletion violates a dependency (model still referenced as a default) and the driver raises a non-domain exception.
Common situations: Deleting a model that is still assigned in DefaultModels; DB outage; transaction conflicts.
Related errors
- Error deleting session: {str(e)}
- Failed to delete credential
- Failed to delete episode profile
- Error deleting insight
- Error fetching models: {str(e)}
AI-assisted analysis of lfnovo/open-notebook@a7de90d38a (2026-08-27).
Data as JSON: /api/errors/f3a3563ebb396ad6.
Report an issue: GitHub.