{"record":{"id":"826372d08ca86849","repo":"lfnovo/open-notebook","slug":"rebuild-command-not-found","errorCode":null,"errorMessage":"Rebuild command not found","messagePattern":"Rebuild command not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"api/routers/embedding_rebuild.py","lineNumber":144,"sourceCode":"\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)\n\n        if not status:\n            raise HTTPException(status_code=404, detail=\"Rebuild command not found\")\n\n        # Build response based on status\n        response = RebuildStatusResponse(\n            command_id=command_id,\n            status=status.status,\n        )\n\n        # Extract metadata from command result\n        if status.result and isinstance(status.result, dict):\n            result = status.result\n\n            # Build progress info\n            if \"total_items\" in result and \"jobs_submitted\" in result:\n                total = result[\"total_items\"]\n                submitted = result[\"jobs_submitted\"]\n                response.progress = RebuildProgress(\n                    processed=submitted,\n                    total=total,","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/lfnovo/open-notebook/blob/a7de90d38aaf18ee85fd661854d35c11e44613e2/api/routers/embedding_rebuild.py#L126-L162","documentation":"HTTP 404 raised by the embedding-rebuild status endpoint when surreal_commands returns no command record for the given command_id. It means the rebuild job either never existed, was garbage-collected, or its ID is malformed.","triggerScenarios":"GET /api/embedding_rebuild/{command_id}/status (get_rebuild_status) where get_command_status(command_id) returns None — wrong/stale command_id from a previous rebuild, or the command store (SurrealDB) was reset/wiped between starting the rebuild and polling its status.","commonSituations":"Frontend polls a rebuild status after a DB reset or after the command record expired; client persists a command_id across server restarts; typo/truncation of the command ID in the URL.","solutions":["Verify the command_id matches the one returned when the rebuild was started (POST endpoint response)","Check that SurrealDB wasn't restarted/reset — surreal_commands state lives there and is lost on reset","If state was lost, simply start a new rebuild and use the new command_id","Inspect surreal_commands table to confirm whether the record exists"],"exampleFix":"// before\nstatus = await get_command_status(\"cmd-123\")\n// after: confirm the id came from the rebuild start response\nresp = await client.post(\"/api/embedding_rebuild\")\ncommand_id = resp.json()[\"command_id\"]\nstatus = await client.get(f\"/api/embedding_rebuild/{command_id}/status\")","handlingStrategy":"validation","validationCode":"resp = await client.get(f\"/api/embedding_rebuild/{command_id}/status\")\nif resp.status_code == 404:\n    # command record gone: restart the rebuild rather than polling a dead id\n    command_id = (await client.post(\"/api/embedding_rebuild\")).json()[\"command_id\"]","typeGuard":null,"tryCatchPattern":"try:\n    status = await get_rebuild_status(command_id)\nexcept HTTPException as e:\n    if e.status_code == 404:\n        command_id = await restart_rebuild()  # get fresh id and stop polling the old one\n    else:\n        raise","preventionTips":["Always take command_id from the start-rebuild response, never hardcode it","Don't persist command ids across DB resets/restarts — they live in surreal_commands state","Stop polling once status is terminal (completed/failed) to avoid hitting expired records"],"tags":["http-404","embedding-rebuild","surreal-commands","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"a7de90d38aaf18ee85fd661854d35c11e44613e2","analyzedAt":"2026-08-27T02:39:58.166Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}