{"record":{"id":"12b27d073d9c27b5","repo":"invoke-ai/InvokeAI","slug":"unexpected-error-while-getting-queue-status-e","errorCode":null,"errorMessage":"Unexpected error while getting queue status: {e}","messagePattern":"Unexpected error while getting queue status: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"invokeai/app/api/routers/session_queue.py","lineNumber":531,"sourceCode":"        200: {\"model\": SessionQueueAndProcessorStatus},\n    },\n)\ndef get_queue_status(\n    current_user: CurrentUserOrDefault,\n    queue_id: str = Path(description=\"The queue id to perform this operation on\"),\n) -> SessionQueueAndProcessorStatus:\n    \"\"\"Gets the status of the session queue. Returns global counts; every user additionally gets\n    their own pending/in_progress counts (so the UI can show an X/Y badge and scope personal UI\n    like the progress bar to the user's own activity). Non-admin users cannot see the current\n    item's identifiers unless they own it.\"\"\"\n    try:\n        queue = ApiDependencies.invoker.services.session_queue.get_queue_status(\n            queue_id, user_id=current_user.user_id, is_admin=current_user.is_admin\n        )\n        processor = ApiDependencies.invoker.services.session_processor.get_status()\n        return SessionQueueAndProcessorStatus(queue=queue, processor=processor)\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=f\"Unexpected error while getting queue status: {e}\")\n\n\n@session_queue_router.get(\n    \"/{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(","sourceCodeStart":513,"sourceCodeEnd":549,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/api/routers/session_queue.py#L513-L549","documentation":"This is a FastAPI HTTPException (500) raised in the GET /session_queue/{queue_id}/status endpoint when any unexpected exception escapes the try block. The service calls session_queue.get_queue_status() and session_processor.get_status(); a failure in either (DB unavailable, serialization error, internal service bug) is wrapped into this generic 500 message with the underlying exception interpolated.","triggerScenarios":"Calling GET /api/v1/session_queue/{queue_id}/status when the SessionQueue service throws: the queue DB is down, get_queue_status raises for a corrupted queue row, or session_processor.get_status() fails. Any exception other than the handled ones lands here.","commonSituations":"SQLite/Postgres connection lost while the server is running; schema migration mismatch after upgrading InvokeAI so the queue tables are missing columns; queue service misconfigured via ApiDependencies (dependency injection not initialized in a custom build).","solutions":["Check the server log / detail string for the interpolated underlying exception {e} and fix that root cause first","Verify the queue database (SQLite file or Postgres) is reachable and migrations have run (invokeai-db-maint / startup migrations)","Confirm ApiDependencies.invoker.services.session_queue and session_processor are initialized (not None) in your setup","Restart the API server to re-establish DB connections if it was running during a DB outage"],"exampleFix":"// before: endpoint fails with opaque 500 when DB is briefly unavailable\nGET /api/v1/session_queue/{queue_id}/status\n// after: retry with backoff on the client, or check DB health first\nif not await is_db_healthy():\n    raise HTTPException(status_code=503, detail='Queue storage unavailable')","handlingStrategy":"try-catch","validationCode":"// client-side pre-check\nconst res = await fetch('/api/v1/session_queue/health', { method: 'GET' })\nif (!res.ok) throw new Error('Queue backend unavailable; skipping status call')","typeGuard":null,"tryCatchPattern":"try {\n  const status = await api.get(`/api/v1/session_queue/${queueId}/status`)\n} catch (e) {\n  if (e.response?.status === 500) {\n    log.error('Queue status failed:', e.response.data?.detail)\n    // fall back to cached status or retry with backoff\n  } else throw e\n}","preventionTips":["Keep the queue DB healthy: monitor connection and run migrations on upgrade","Read the {e} detail in the 500 to identify the true root cause before retrying","Add retry with exponential backoff for transient DB errors"],"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"}