{"record":{"id":"79b256c76bbb1404","repo":"lfnovo/open-notebook","slug":"embed-request-item-type-not-found","errorCode":null,"errorMessage":"{embed_request.item_type} not found","messagePattern":"(.+?) not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"api/routers/embedding.py","lineNumber":118,"sourceCode":"                command_id = await note_item.save()\n                if not command_id and note_item.content and note_item.content.strip():\n                    raise HTTPException(\n                        status_code=500, detail=\"Failed to submit note embedding job\"\n                    )\n                message = \"Note embedding job submitted\"\n\n            return EmbedResponse(\n                success=True,\n                message=message,\n                item_id=item_id,\n                item_type=item_type,\n                command_id=command_id,\n            )\n\n    except HTTPException:\n        raise\n    except NotFoundError:\n        raise HTTPException(\n            status_code=404, detail=f\"{embed_request.item_type} not found\"\n        )\n    except OpenNotebookError:\n        raise\n    except Exception as e:\n        logger.error(\n            f\"Error embedding {embed_request.item_type} {embed_request.item_id}: {str(e)}\"\n        )\n        raise HTTPException(\n            status_code=500, detail=f\"Error embedding content: {str(e)}\"\n        )\n","sourceCodeStart":100,"sourceCodeEnd":130,"githubUrl":"https://github.com/lfnovo/open-notebook/blob/a7de90d38aaf18ee85fd661854d35c11e44613e2/api/routers/embedding.py#L100-L130","documentation":"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').","triggerScenarios":"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.","commonSituations":"Client holds a stale item ID (item deleted in UI), race between delete and embed, or copy/paste error in the ID.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const exists = await (itemType === 'source' ? api.getSource(itemId) : api.getNote(itemId)).then(() => true).catch(() => false);\nif (!exists) throw new Error(`${itemType} ${itemId} not found — refresh IDs`);","typeGuard":null,"tryCatchPattern":"try {\n  await api.embed({ item_id: itemId, item_type: itemType });\n} catch (e) {\n  if (e.status === 404) { evictFromCache(itemType, itemId); return; }\n  throw e;\n}","preventionTips":["Refresh item lists before embedding stale references","Use exact full database IDs, never truncated copies"],"tags":["embedding","not-found","http-404"],"backgroundTag":"resource-not-found","analyzedSha":"a7de90d38aaf18ee85fd661854d35c11e44613e2","analyzedAt":"2026-08-27T02:39:58.166Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}