{"record":{"id":"6c11b6c7d2d79d9f","repo":"lfnovo/open-notebook","slug":"failed-to-start-rebuild-operation-str-e","errorCode":null,"errorMessage":"Failed to start rebuild operation: {str(e)}","messagePattern":"Failed to start rebuild operation: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"api/routers/embedding_rebuild.py","lineNumber":123,"sourceCode":"            },\n        )\n\n        logger.info(f\"Submitted rebuild command: {command_id}\")\n\n        return RebuildResponse(\n            command_id=command_id,\n            total_items=total_estimate,\n            message=f\"Rebuild operation started. Estimated {total_estimate} items to process.\",\n        )\n\n    except HTTPException:\n        raise\n    except OpenNotebookError:\n        raise\n    except Exception as e:\n        logger.error(f\"Failed to start rebuild: {e}\")\n        logger.exception(e)\n        raise HTTPException(\n            status_code=500, detail=f\"Failed to start rebuild operation: {str(e)}\"\n        )\n\n\n@router.get(\"/rebuild/{command_id}/status\", response_model=RebuildStatusResponse)\nasync def get_rebuild_status(command_id: str):\n    \"\"\"\n    Get the status of a rebuild operation.\n\n    Returns:\n    - **status**: queued, running, completed, failed\n    - **progress**: processed count, total count, percentage\n    - **stats**: breakdown by type (sources, notes, insights, failed)\n    - **timestamps**: started_at, completed_at\n    \"\"\"\n    try:\n        # Get command status from surreal_commands\n        status = await get_command_status(command_id)","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/lfnovo/open-notebook/blob/a7de90d38aaf18ee85fd661854d35c11e44613e2/api/routers/embedding_rebuild.py#L105-L141","documentation":"Catch-all 500 from the rebuild-start endpoint (POST /api/embeddings/rebuild or similar in embedding_rebuild.py). Starting a vector rebuild submits a long-running command; any unexpected failure in setup (job submission, DB access, config resolution) aborts with this error, with the cause appended.","triggerScenarios":"Triggering a full embedding rebuild when command submission to the job queue fails or the DB is unreachable — e.g. worker tier or SurrealDB down, or an embedding model resolution error before the job starts.","commonSituations":"Running 'rebuild embeddings' before starting the worker (make worker-start), no default embedding model configured, or DB restart mid-submission. The endpoint logs the full traceback (logger.exception) alongside the error line.","solutions":["Check API logs for the 'Failed to start rebuild: ...' line plus full traceback","Ensure the whole stack is up in order: make database, make api, make worker-start","Confirm a default embedding model is configured before rebuilding","Retry the rebuild start once healthy; check rebuild status via GET /rebuild/{command_id}/status for the accepted job"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// pre-flight before rebuild: stack up + embedding model set\nconst models = await api.listModels();\nif (!models.some(m => m.isDefault && m.type === 'embedding')) throw new Error('Set a default embedding model before rebuild');\n// server-side: make database && make api && make worker-start all healthy","typeGuard":null,"tryCatchPattern":"try {\n  const { command_id } = await api.startRebuild();\n  await poll(`/rebuild/${command_id}/status`);\n} catch (e) {\n  if (e.status === 500) showError('Could not start rebuild — is the worker running?');\n  throw e;\n}","preventionTips":["Start the worker before triggering rebuilds; async jobs silently fail without it","Check the API log traceback (logger.exception) when a rebuild start fails","Track rebuild progress via the status endpoint instead of assuming success"],"tags":["embedding","rebuild","job-queue","http-500"],"backgroundTag":"background-job-submission-failed","analyzedSha":"a7de90d38aaf18ee85fd661854d35c11e44613e2","analyzedAt":"2026-08-27T02:39:58.166Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}