lfnovo/open-notebook · error · HTTPException
Error deleting insight
Error message
Error deleting insight
What it means
Generic 500 from DELETE /api/insights/{insight_id} when insight.delete() raises an unexpected exception.
Source
Thrown at api/routers/insights.py:60
@router.delete("/insights/{insight_id}")
async def delete_insight(insight_id: str):
"""Delete a specific insight."""
try:
insight = await SourceInsight.get(insight_id)
if not insight:
raise HTTPException(status_code=404, detail="Insight not found")
await insight.delete()
return {"message": "Insight deleted successfully"}
except HTTPException:
raise
except OpenNotebookError:
raise
except Exception as e:
logger.error(f"Error deleting insight {insight_id}: {str(e)}")
raise HTTPException(status_code=500, detail="Error deleting insight")
@router.post("/insights/{insight_id}/save-as-note", response_model=NoteResponse)
async def save_insight_as_note(insight_id: str, request: SaveAsNoteRequest):
"""Convert an insight to a note."""
try:
insight = await SourceInsight.get(insight_id)
if not insight:
raise HTTPException(status_code=404, detail="Insight not found")
# Use the existing save_as_note method from the domain model
note = await insight.save_as_note(request.notebook_id)
return NoteResponse(
id=note.id or "",
title=note.title,
content=note.content,
note_type=note.note_type,View on GitHub (pinned to a7de90d38a)
Solutions
- Check the log 'Error deleting insight <id>' for the cause
- Verify DB connectivity/permissions and retry
- Handle 404-on-retry as success (already deleted)
- Investigate driver errors for table-level constraints
Defensive patterns
Strategy: retry
Try / catch
for attempt in range(2):
resp = await client.delete(f"/api/insights/{insight_id}")
if resp.status_code < 500 or resp.status_code == 404 or attempt:
break
await asyncio.sleep(1) Prevention
- Check server logs for the root exception
- Ensure DB user has delete permission on insights table
- Avoid issuing parallel deletes of the same insight
When it happens
Trigger: DB outage/timeout during delete, driver-level permission error on the insight table, or record conflicts during concurrent deletes.
Common situations: SurrealDB restart mid-request, restricted DB credentials, concurrent modification of the same insight.
Related errors
- Error deleting session: {str(e)}
- Failed to delete episode profile
- Error fetching insight
- Error saving insight as note
- Error fetching chat sessions: {str(e)}
AI-assisted analysis of lfnovo/open-notebook@a7de90d38a (2026-08-27).
Data as JSON: /api/errors/ee0b634290bfea62.
Report an issue: GitHub.