{"record":{"id":"a8e6c0b84a33d0a1","repo":"lfnovo/open-notebook","slug":"label-record-id-has-no-content-to-embed","errorCode":null,"errorMessage":"{label} '{record_id}' has no content to embed","messagePattern":"(.+?) '(.+?)' has no content to embed","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"commands/embedding_commands.py","lineNumber":116,"sourceCode":"\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        },\n    )\n\n    return {}, \"\"","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/lfnovo/open-notebook/blob/a7de90d38aaf18ee85fd661854d35c11e44613e2/commands/embedding_commands.py#L98-L134","documentation":"ValueError raised by _embed_markdown_record when the loaded note/insight exists but has empty or whitespace-only content. Embedding requires text, so the guard fails fast before calling generate_embedding.","triggerScenarios":"Running embed_note/embed_insight on a note or insight whose content field is '' or only whitespace — e.g. a user created a note shell but never typed content.","commonSituations":"UI creates an empty insight draft and the embedding job fires before content is saved; bulk-imported notes with missing content fields.","solutions":["Open the note/insight and add actual content, then resubmit the embedding command","If importing notes, skip records with empty content at import time","Filter empty records before bulk embedding jobs"],"exampleFix":"// before\nsubmit_command('open_notebook', 'embed_note', {'note_id': nid})\n// after\nnote = await Note.get(nid)\nif note and note.content and note.content.strip():\n    submit_command('open_notebook', 'embed_note', {'note_id': nid})","handlingStrategy":"validation","validationCode":"record = await loader(record_id)\nif not record.content or not record.content.strip():\n    skip('record has no content to embed')","typeGuard":"def has_embeddable_content(record) -> bool:\n    return bool(record and record.content and record.content.strip())","tryCatchPattern":null,"preventionTips":["Require non-empty content before creating notes/insights that trigger embedding","Skip empty records in bulk embedding pipelines","Save content before submitting the embed job"],"tags":["python","valueerror","embedding","empty-content","note","insight"],"backgroundTag":"empty-input-validation","analyzedSha":"a7de90d38aaf18ee85fd661854d35c11e44613e2","analyzedAt":"2026-08-27T02:39:58.166Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}