{"record":{"id":"39181994f127a332","repo":"invoke-ai/InvokeAI","slug":"unexpected-error-while-listing-all-queue-items-e","errorCode":null,"errorMessage":"Unexpected error while listing all queue items: {e}","messagePattern":"Unexpected error while listing all queue items: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"invokeai/app/api/routers/session_queue.py","lineNumber":165,"sourceCode":"    responses={\n        200: {\"model\": list[SessionQueueItem]},\n    },\n)\ndef list_all_queue_items(\n    current_user: CurrentUserOrDefault,\n    queue_id: str = Path(description=\"The queue id to perform this operation on\"),\n    destination: Optional[str] = Query(default=None, description=\"The destination of queue items to fetch\"),\n) -> list[SessionQueueItem]:\n    \"\"\"Gets all queue items\"\"\"\n    try:\n        items = ApiDependencies.invoker.services.session_queue.list_all_queue_items(\n            queue_id=queue_id,\n            destination=destination,\n        )\n        # Sanitize items for non-admin users\n        return [sanitize_queue_item_for_user(item, current_user.user_id, current_user.is_admin) for item in items]\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=f\"Unexpected error while listing all queue items: {e}\")\n\n\n@session_queue_router.get(\n    \"/{queue_id}/item_ids\",\n    operation_id=\"get_queue_item_ids\",\n    responses={\n        200: {\"model\": ItemIdsResult},\n    },\n)\ndef get_queue_item_ids(\n    current_user: CurrentUserOrDefault,\n    queue_id: str = Path(description=\"The queue id to perform this operation on\"),\n    order_dir: SQLiteDirection = Query(default=SQLiteDirection.Descending, description=\"The order of sort\"),\n) -> ItemIdsResult:\n    \"\"\"Gets all queue item ids that match the given parameters.\n\n    IDs for every user's items are returned (item ids carry no sensitive data on their own).\n    When the corresponding items are hydrated via get_queue_items_by_item_ids, those belonging","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/api/routers/session_queue.py#L147-L183","documentation":"Catch-all in the list_all_queue_items endpoint: any failure while fetching the full queue item list (or sanitizing items per-user) becomes a 500 whose detail carries the underlying exception text. Thrown because the router treats all service-layer failures identically rather than mapping known errors (e.g. InvalidQueueIDError) to 4xx responses.","triggerScenarios":"GET /{queue_id}/list_all (optionally with destination param) when the queue service raises - nonexistent queue_id, DB query failure, or an exception raised during sanitize_queue_item_for_user on a malformed stored item.","commonSituations":"Polling a queue id from a different InvokeAI instance than the one serving the request; multiuser setups where a stored item lacks fields the sanitizer expects; transient SQLite locking under heavy queue load.","solutions":["Inspect the detail string - it contains the underlying exception; address that specific cause","Confirm queue_id matches a queue on the running instance","If it happens with multiuser enabled, check stored queue items for malformed data the sanitizer cannot handle","Retry under lighter DB load or after restarting if SQLite lock contention is suspected"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const q = await fetch(`/api/v1/queue/${queueId}`);\nif (!q.ok) throw new Error(`Unknown queue_id: ${queueId}`);","typeGuard":"function isQueueItemList(v) { return Array.isArray(v) && v.every(i => i && typeof i === 'object' && 'item_id' in i); }","tryCatchPattern":"try {\n  const res = await fetch(`/api/v1/queue/${queueId}/list_all`);\n  if (!res.ok) { console.error('list_all failed:', (await res.json()).detail); return []; }\n  return await res.json();\n} catch { return []; }","preventionTips":["Use the same instance's queue ids you created the work on","Reduce polling frequency to avoid SQLite contention under load","In multiuser mode, watch for sanitizer failures on legacy data","Log the detail string - it contains the actual exception"],"tags":["fastapi","http-500","queue","api"],"backgroundTag":"api-internal-server-error","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}