lfnovo/open-notebook · error · HTTPException
{embed_request.item_type} not found
Error message
{embed_request.item_type} not found What it means
404 from POST /api/embed when the item being embedded does not exist: NotFoundError from the domain layer is translated to 404 with the requested item_type interpolated into the message ('source not found' / 'note not found').
Source
Thrown at api/routers/embedding.py:118
command_id = await note_item.save()
if not command_id and note_item.content and note_item.content.strip():
raise HTTPException(
status_code=500, detail="Failed to submit note embedding job"
)
message = "Note embedding job submitted"
return EmbedResponse(
success=True,
message=message,
item_id=item_id,
item_type=item_type,
command_id=command_id,
)
except HTTPException:
raise
except NotFoundError:
raise HTTPException(
status_code=404, detail=f"{embed_request.item_type} not found"
)
except OpenNotebookError:
raise
except Exception as e:
logger.error(
f"Error embedding {embed_request.item_type} {embed_request.item_id}: {str(e)}"
)
raise HTTPException(
status_code=500, detail=f"Error embedding content: {str(e)}"
)
View on GitHub (pinned to a7de90d38a)
Solutions
- Verify the item exists: GET the corresponding source or note endpoint with the same ID
- If deleted, drop the embed request or re-create the item first
- Ensure the ID is the full, exact database ID (no truncation or extra whitespace)
- Refresh the client's item list to avoid stale IDs
Defensive patterns
Strategy: validation
Validate before calling
const exists = await (itemType === 'source' ? api.getSource(itemId) : api.getNote(itemId)).then(() => true).catch(() => false);
if (!exists) throw new Error(`${itemType} ${itemId} not found — refresh IDs`); Try / catch
try {
await api.embed({ item_id: itemId, item_type: itemType });
} catch (e) {
if (e.status === 404) { evictFromCache(itemType, itemId); return; }
throw e;
} Prevention
- Refresh item lists before embedding stale references
- Use exact full database IDs, never truncated copies
When it happens
Trigger: POST /api/embed with an item_id that was deleted, belongs to another notebook, or is malformed — the lookup inside the embed flow raises NotFoundError before any embedding starts.
Common situations: Client holds a stale item ID (item deleted in UI), race between delete and embed, or copy/paste error in the ID.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Session not found
- Credential not found
- Rebuild command not found
- Episode profile '{profile_name}' not found
- Episode profile '{profile_id}' not found
AI-assisted analysis of lfnovo/open-notebook@a7de90d38a (2026-08-27).
Data as JSON: /api/errors/79b256c76bbb1404.
Report an issue: GitHub.