{"record":{"id":"0086ad6c618ca4ae","repo":"invoke-ai/InvokeAI","slug":"unexpected-error-while-getting-batch-status-e","errorCode":null,"errorMessage":"Unexpected error while getting batch status: {e}","messagePattern":"Unexpected error while getting batch status: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"invokeai/app/api/routers/session_queue.py","lineNumber":553,"sourceCode":"    \"/{queue_id}/b/{batch_id}/status\",\n    operation_id=\"get_batch_status\",\n    responses={\n        200: {\"model\": BatchStatus},\n    },\n)\ndef get_batch_status(\n    current_user: CurrentUserOrDefault,\n    queue_id: str = Path(description=\"The queue id to perform this operation on\"),\n    batch_id: str = Path(description=\"The batch to get the status of\"),\n) -> BatchStatus:\n    \"\"\"Gets the status of a batch. Non-admin users only see their own batches.\"\"\"\n    try:\n        user_id = None if current_user.is_admin else current_user.user_id\n        return ApiDependencies.invoker.services.session_queue.get_batch_status(\n            queue_id=queue_id, batch_id=batch_id, user_id=user_id\n        )\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=f\"Unexpected error while getting batch status: {e}\")\n\n\n@session_queue_router.get(\n    \"/{queue_id}/i/{item_id}\",\n    operation_id=\"get_queue_item\",\n    responses={\n        200: {\"model\": SessionQueueItem},\n    },\n    response_model_exclude_none=True,\n)\ndef get_queue_item(\n    current_user: CurrentUserOrDefault,\n    queue_id: str = Path(description=\"The queue id to perform this operation on\"),\n    item_id: int = Path(description=\"The queue item to get\"),\n) -> SessionQueueItem:\n    \"\"\"Gets a queue item\"\"\"\n    try:\n        queue_item = ApiDependencies.invoker.services.session_queue.get_queue_item(item_id=item_id)","sourceCodeStart":535,"sourceCodeEnd":571,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/api/routers/session_queue.py#L535-L571","documentation":"HTTPException(500) raised by the GET /session_queue/{queue_id}/b/{batch_id}/status endpoint when ApiDependencies.invoker.services.session_queue.get_batch_status() throws any unhandled exception. The endpoint simply delegates to the queue service (scoping to the caller's user_id unless admin), so any storage or service-layer failure surfaces as this generic 500.","triggerScenarios":"Calling GET /api/v1/session_queue/{queue_id}/b/{batch_id}/status when get_batch_status raises: batch row corrupt, DB connection dropped, or an invalid batch_id type slipping past validation into the service.","commonSituations":"Database unavailable or locked (SQLite lock contention during heavy queue usage); version upgrade left the batches table missing; passing a batch_id that was deleted concurrently.","solutions":["Read the interpolated {e} in the response detail to identify the underlying exception","Check database connectivity and lock contention on the queue store","Verify the batch_id exists (list batches via the queue status endpoint) and matches the queue_id","Re-run DB migrations if the schema was changed by an upgrade"],"exampleFix":"// before\nconst status = await fetch(`/api/v1/session_queue/${queueId}/b/${batchId}/status`)\n// after: validate batch exists before fetching full status\nconst batches = await getQueueBatches(queueId)\nif (!batches.some(b => b.batch_id === batchId)) throw new Error(`Batch ${batchId} not in queue ${queueId}`)","handlingStrategy":"try-catch","validationCode":"// verify batch exists before requesting status\nconst queue = await api.get(`/api/v1/session_queue/${queueId}/status`)\nif (!queue.data.queue.batches.some(b => b.batch_id === batchId)) {\n  throw new Error(`Batch ${batchId} not present in queue ${queueId}`)\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await api.get(`/api/v1/session_queue/${queueId}/b/${batchId}/status`)\n} catch (e) {\n  if (e.response?.status === 500) { log.warn(e.response.data?.detail); return null }\n  throw e\n}","preventionTips":["Validate batch_id against the queue's batch list before querying","Check DB health/lock state during heavy queue usage","Re-run migrations after InvokeAI upgrades"],"tags":["fastapi","http-500","queue","database"],"backgroundTag":"unexpected-internal-server-error","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}