{"record":{"id":"741cd795c077e8ce","repo":"lfnovo/open-notebook","slug":"failed-to-fetch-job-status","errorCode":null,"errorMessage":"Failed to fetch job status","messagePattern":"Failed to fetch job status","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"api/routers/commands.py","lineNumber":94,"sourceCode":"        raise HTTPException(\n            status_code=500, detail=\"Failed to submit command\"\n        )\n\n\n@router.get(\"/commands/jobs/{job_id}\", response_model=CommandJobStatusResponse)\nasync def get_command_job_status(job_id: str):\n    \"\"\"Get the status of a specific command job\"\"\"\n    try:\n        status_data = await CommandService.get_command_status(job_id)\n        return CommandJobStatusResponse(**status_data)\n\n    except HTTPException:\n        raise\n    except OpenNotebookError:\n        raise\n    except Exception as e:\n        logger.error(f\"Error fetching job status: {str(e)}\")\n        raise HTTPException(\n            status_code=500, detail=\"Failed to fetch job status\"\n        )\n\n\n@router.get(\"/commands/jobs\", response_model=List[Dict[str, Any]])\nasync def list_command_jobs(\n    command_filter: Optional[str] = Query(None, description=\"Filter by command name\"),\n    status_filter: Optional[str] = Query(None, description=\"Filter by status\"),\n    limit: int = Query(50, description=\"Maximum number of jobs to return\"),\n):\n    \"\"\"List command jobs with optional filtering\"\"\"\n    try:\n        jobs = await CommandService.list_command_jobs(\n            command_filter=command_filter, status_filter=status_filter, limit=limit\n        )\n        return jobs\n\n    except HTTPException:","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/lfnovo/open-notebook/blob/a7de90d38aaf18ee85fd661854d35c11e44613e2/api/routers/commands.py#L76-L112","documentation":"500 from GET /commands/jobs/{job_id} when querying job status throws an unexpected exception (not a mapped NotFound/OpenNotebook error). Logged as 'Error fetching job status: ...'.","triggerScenarios":"Job store unreadable, connection failure to SurrealDB, or job record with a shape the status parser can't handle.","commonSituations":"SurrealDB restarted losing in-memory/job state; querying a job id from a wiped DB; version mismatch between job records and current parser.","solutions":["Check the API log for the underlying exception","Confirm SurrealDB and worker are running","If the job truly vanished, resubmit the command instead of polling the old job id"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (e) { if (e.status === 500) stopPollingAndAlert(); else throw e; }","preventionTips":["Poll with a timeout; abandon stale job ids after DB resets","Monitor worker health"],"tags":["http-500","job-status","worker"],"backgroundTag":"job-queue-status-failed","analyzedSha":"a7de90d38aaf18ee85fd661854d35c11e44613e2","analyzedAt":"2026-08-27T02:39:58.166Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}