{"record":{"id":"77f19ed5f5264f3b","repo":"lfnovo/open-notebook","slug":"failed-to-create-insight-no-result-returned","errorCode":null,"errorMessage":"Failed to create insight - no result returned","messagePattern":"Failed to create insight - no result returned","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"commands/embedding_commands.py","lineNumber":452,"sourceCode":"\n        # 1. Create insight record in database\n        result = await repo_query(\n            \"\"\"\n            CREATE source_insight CONTENT {\n                \"source\": $source_id,\n                \"insight_type\": $insight_type,\n                \"content\": $content\n            };\n            \"\"\",\n            {\n                \"source_id\": ensure_record_id(input_data.source_id),\n                \"insight_type\": input_data.insight_type,\n                \"content\": input_data.content,\n            },\n        )\n\n        if not result or len(result) == 0:\n            raise ValueError(\"Failed to create insight - no result returned\")\n\n        insight_id = str(result[0].get(\"id\", \"\"))\n        if not insight_id:\n            raise ValueError(\"Failed to create insight - no ID in result\")\n\n        # 2. Submit embedding command (fire-and-forget)\n        submit_command(\n            \"open_notebook\",\n            \"embed_insight\",\n            {\"insight_id\": insight_id},\n        )\n        logger.debug(f\"Submitted embed_insight command for {insight_id}\")\n\n        processing_time = time.time() - start_time\n        logger.info(\n            f\"Successfully created insight {insight_id} for source \"\n            f\"{input_data.source_id} in {processing_time:.2f}s\"\n        )","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/lfnovo/open-notebook/blob/a7de90d38aaf18ee85fd661854d35c11e44613e2/commands/embedding_commands.py#L434-L470","documentation":"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.","triggerScenarios":"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.","commonSituations":"SurrealDB version upgrade changing insert-return behavior, connection pool returning a dead session, or permissions restricting the insight table.","solutions":["Retry the create-insight call — transient DB hiccups are the most common cause","Check SurrealDB health and the worker logs around the failure","Verify the SurrealDB version matches what this Open Notebook release expects","Manually test an INSERT on the insight table in SurrealDB to confirm it returns results"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for attempt in range(3):\n    result = await run_command('create_insight', payload)\n    if result.output.get('success'):\n        break\n    await asyncio.sleep(2 ** attempt)\nelse:\n    raise RuntimeError('insight creation repeatedly returned no result')","preventionTips":["Retry transient empty insert results with backoff","Keep SurrealDB version aligned with project requirements","Check for partial insight records after repeated failures"],"tags":["python","valueerror","insight","surrealdb","insert"],"backgroundTag":"database-insert-no-result","analyzedSha":"a7de90d38aaf18ee85fd661854d35c11e44613e2","analyzedAt":"2026-08-27T02:39:58.166Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}