{"record":{"id":"4454f278e345b989","repo":"lfnovo/open-notebook","slug":"label-record-id-not-found","errorCode":null,"errorMessage":"{label} '{record_id}' not found","messagePattern":"(.+?) '(.+?)' not found","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"commands/embedding_commands.py","lineNumber":113,"sourceCode":"        )\n        raise\n\n\nasync def _embed_markdown_record(\n    input_data: CommandInput,\n    *,\n    label: str,\n    record_id: str,\n    loader: Callable[[str], Awaitable[Any]],\n) -> Tuple[Dict[str, Any], str]:\n    \"\"\"\n    Load a record, validate its content, embed it as markdown and UPSERT the\n    embedding back onto the record. Shared by embed_note and embed_insight.\n    \"\"\"\n    # 1. Load record\n    record = await loader(record_id)\n    if not record:\n        raise ValueError(f\"{label} '{record_id}' not found\")\n\n    if not record.content or not record.content.strip():\n        raise ValueError(f\"{label} '{record_id}' has no content to embed\")\n\n    # 2. Generate embedding (auto-chunks + mean pools if needed)\n    # Notes and insights are typically markdown content\n    cmd_id = get_command_id(input_data)\n    embedding = await generate_embedding(\n        record.content, content_type=ContentType.MARKDOWN, command_id=cmd_id\n    )\n\n    # 3. UPSERT embedding into the record\n    await repo_query(\n        \"UPDATE $record_id SET embedding = $embedding\",\n        {\n            \"record_id\": ensure_record_id(record_id),\n            \"embedding\": embedding,\n        },","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/lfnovo/open-notebook/blob/a7de90d38aaf18ee85fd661854d35c11e44613e2/commands/embedding_commands.py#L95-L131","documentation":"ValueError raised by the shared _embed_markdown_record helper (used by embed_note and embed_insight commands) when the loader callable returns no record for the given record_id. It is a precondition check before any embedding work starts.","triggerScenarios":"Submitting the embed_note or embed_insight command with a note_id/insight_id that was deleted or never existed. Per the module's own note, the ValueError is caught by the command wrapper and returned as success=False rather than raising to the retry layer.","commonSituations":"Fire-and-forget embedding jobs racing with record deletion (create_insight_command submits embed_insight immediately), or replaying old command payloads after a DB reset.","solutions":["Verify the note/insight ID exists in SurrealDB before resubmitting","Check the command's result payload — it will carry success=False with this message","If the record was deleted, no embedding is needed; drop the job","If the record should exist, check you are connected to the correct database"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"note = await Note.get(note_id)  # or Insight.get(insight_id)\nif not note:\n    raise KeyError(f'{note_id} does not exist')","typeGuard":null,"tryCatchPattern":"result = await run_command('embed_note', {'note_id': nid})\nif not result.output.get('success'):\n    msg = result.output.get('error', '')\n    if 'not found' in msg:\n        return  # record gone; nothing to embed","preventionTips":["Verify the record exists before submitting embedding jobs","Expect success=False (not raised exceptions) from embed commands","Avoid submitting embed jobs for records pending deletion"],"tags":["python","valueerror","embedding","note","insight","not-found"],"backgroundTag":"record-not-found","analyzedSha":"a7de90d38aaf18ee85fd661854d35c11e44613e2","analyzedAt":"2026-08-27T02:39:58.166Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}