lfnovo/open-notebook · warning · ValueError

{label} '{record_id}' has no content to embed

Error message

{label} '{record_id}' has no content to embed

What it means

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.

Source

Thrown at commands/embedding_commands.py:116

async def _embed_markdown_record(
    input_data: CommandInput,
    *,
    label: str,
    record_id: str,
    loader: Callable[[str], Awaitable[Any]],
) -> Tuple[Dict[str, Any], str]:
    """
    Load a record, validate its content, embed it as markdown and UPSERT the
    embedding back onto the record. Shared by embed_note and embed_insight.
    """
    # 1. Load record
    record = await loader(record_id)
    if not record:
        raise ValueError(f"{label} '{record_id}' not found")

    if not record.content or not record.content.strip():
        raise ValueError(f"{label} '{record_id}' has no content to embed")

    # 2. Generate embedding (auto-chunks + mean pools if needed)
    # Notes and insights are typically markdown content
    cmd_id = get_command_id(input_data)
    embedding = await generate_embedding(
        record.content, content_type=ContentType.MARKDOWN, command_id=cmd_id
    )

    # 3. UPSERT embedding into the record
    await repo_query(
        "UPDATE $record_id SET embedding = $embedding",
        {
            "record_id": ensure_record_id(record_id),
            "embedding": embedding,
        },
    )

    return {}, ""

View on GitHub (pinned to a7de90d38a)

Solutions

  1. Open the note/insight and add actual content, then resubmit the embedding command
  2. If importing notes, skip records with empty content at import time
  3. Filter empty records before bulk embedding jobs

Example fix

// before
submit_command('open_notebook', 'embed_note', {'note_id': nid})
// after
note = await Note.get(nid)
if note and note.content and note.content.strip():
    submit_command('open_notebook', 'embed_note', {'note_id': nid})
Defensive patterns

Strategy: validation

Validate before calling

record = await loader(record_id)
if not record.content or not record.content.strip():
    skip('record has no content to embed')

Type guard

def has_embeddable_content(record) -> bool:
    return bool(record and record.content and record.content.strip())

Prevention

When it happens

Trigger: 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.

Common situations: UI creates an empty insight draft and the embedding job fires before content is saved; bulk-imported notes with missing content fields.

Related errors


AI-assisted analysis of lfnovo/open-notebook@a7de90d38a (2026-08-27). Data as JSON: /api/errors/a8e6c0b84a33d0a1. Report an issue: GitHub.