lfnovo/open-notebook · warning · ValueError

{label} '{record_id}' not found

Error message

{label} '{record_id}' not found

What it means

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.

Source

Thrown at commands/embedding_commands.py:113

        )
        raise


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,
        },

View on GitHub (pinned to a7de90d38a)

Solutions

  1. Verify the note/insight ID exists in SurrealDB before resubmitting
  2. Check the command's result payload — it will carry success=False with this message
  3. If the record was deleted, no embedding is needed; drop the job
  4. If the record should exist, check you are connected to the correct database
Defensive patterns

Strategy: validation

Validate before calling

note = await Note.get(note_id)  # or Insight.get(insight_id)
if not note:
    raise KeyError(f'{note_id} does not exist')

Try / catch

result = await run_command('embed_note', {'note_id': nid})
if not result.output.get('success'):
    msg = result.output.get('error', '')
    if 'not found' in msg:
        return  # record gone; nothing to embed

Prevention

When it happens

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

Common situations: 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.

Related errors


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