lfnovo/open-notebook · error · ValueError

Failed to create insight - no result returned

Error message

Failed to create insight - no result returned

What it means

ValueError raised by create_insight_command when the SurrealDB insert of the new insight returns an empty or null result. The CREATE-via-repo_insert is expected to return the created record; an empty result means the database accepted the call but returned nothing usable.

Source

Thrown at commands/embedding_commands.py:452

        # 1. Create insight record in database
        result = await repo_query(
            """
            CREATE source_insight CONTENT {
                "source": $source_id,
                "insight_type": $insight_type,
                "content": $content
            };
            """,
            {
                "source_id": ensure_record_id(input_data.source_id),
                "insight_type": input_data.insight_type,
                "content": input_data.content,
            },
        )

        if not result or len(result) == 0:
            raise ValueError("Failed to create insight - no result returned")

        insight_id = str(result[0].get("id", ""))
        if not insight_id:
            raise ValueError("Failed to create insight - no ID in result")

        # 2. Submit embedding command (fire-and-forget)
        submit_command(
            "open_notebook",
            "embed_insight",
            {"insight_id": insight_id},
        )
        logger.debug(f"Submitted embed_insight command for {insight_id}")

        processing_time = time.time() - start_time
        logger.info(
            f"Successfully created insight {insight_id} for source "
            f"{input_data.source_id} in {processing_time:.2f}s"
        )

View on GitHub (pinned to a7de90d38a)

Solutions

  1. Retry the create-insight call — transient DB hiccups are the most common cause
  2. Check SurrealDB health and the worker logs around the failure
  3. Verify the SurrealDB version matches what this Open Notebook release expects
  4. Manually test an INSERT on the insight table in SurrealDB to confirm it returns results
Defensive patterns

Strategy: retry

Try / catch

for attempt in range(3):
    result = await run_command('create_insight', payload)
    if result.output.get('success'):
        break
    await asyncio.sleep(2 ** attempt)
else:
    raise RuntimeError('insight creation repeatedly returned no result')

Prevention

When it happens

Trigger: Creating an insight while SurrealDB returns an empty result set for the insert — connectivity degradation, SurrealDB version behavior differences on RETURN clauses, or a query syntax/permission issue silently producing no rows.

Common situations: SurrealDB version upgrade changing insert-return behavior, connection pool returning a dead session, or permissions restricting the insight table.

Related errors


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