{"record":{"id":"c556bae7aa1dbf39","repo":"invoke-ai/InvokeAI","slug":"unexpected-error-while-listing-all-queue-item-ids","errorCode":null,"errorMessage":"Unexpected error while listing all queue item ids: {e}","messagePattern":"Unexpected error while listing all queue item ids: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"invokeai/app/api/routers/session_queue.py","lineNumber":193,"sourceCode":"def 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\n    to other users are redacted by sanitize_queue_item_for_user. This lets a non-admin see\n    partially-redacted entries for other users' jobs in the queue list, while still revealing\n    only timestamps and status for items they do not own.\n\n    current_user is required so the endpoint stays behind authentication in multiuser mode.\n    \"\"\"\n    try:\n        return ApiDependencies.invoker.services.session_queue.get_queue_item_ids(queue_id=queue_id, order_dir=order_dir)\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=f\"Unexpected error while listing all queue item ids: {e}\")\n\n\n@session_queue_router.post(\n    \"/{queue_id}/items_by_ids\",\n    operation_id=\"get_queue_items_by_item_ids\",\n    responses={200: {\"model\": list[SessionQueueItem]}},\n)\ndef get_queue_items_by_item_ids(\n    current_user: CurrentUserOrDefault,\n    queue_id: str = Path(description=\"The queue id to perform this operation on\"),\n    item_ids: list[int] = Body(\n        embed=True,\n        max_length=MAX_QUEUE_ITEM_IDS_PER_REQUEST,\n        description=\"Object containing list of queue item ids to fetch queue items for\",\n    ),\n) -> list[SessionQueueItem]:\n    \"\"\"Gets queue items for the specified queue item ids. Maintains order of item ids.\n","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/api/routers/session_queue.py#L175-L211","documentation":"Thrown by get_queue_item_ids when the underlying SessionQueue.get_queue_item_ids call raises any exception; the router wraps it in a 500 with the exception message embedded in the detail. It exists as a safety net so the endpoint always returns a structured HTTP error instead of crashing the ASGI handler.","triggerScenarios":"GET /{queue_id}/item_ids (with order_dir) when queue_id is invalid/unknown, the database query fails, or the service layer throws for any other reason.","commonSituations":"Typo'd or stale queue_id (e.g. 'default' on an instance using a different default queue id); a changed order_dir parameter value unsupported by the installed version; DB access errors.","solutions":["Check the detail message for the underlying exception","Validate queue_id against GET /queue/{queue_id} or list of queues before calling","Use a supported order_dir value ('ASC'/'DESC') for your InvokeAI version","Investigate DB errors (locked file, permissions) if the message points at sqlite"],"exampleFix":"// before\nGET /api/v1/queue/wrong-queue-id/item_ids  // 500\n// after\nconst q = await fetch('/api/v1/queue/wrong-queue-id');\nif (q.ok) await fetch('/api/v1/queue/wrong-queue-id/item_ids');","handlingStrategy":"validation","validationCode":"const q = await fetch(`/api/v1/queue/${queueId}`);\nif (!q.ok) throw new Error(`Queue ${queueId} not found`);\nif (!['ASC','DESC'].includes(order_dir)) throw new Error(`Invalid order_dir: ${order_dir}`);","typeGuard":"function isItemIdList(v) { return Array.isArray(v) && v.every(n => typeof n === 'number' || typeof n === 'string'); }","tryCatchPattern":"try {\n  const res = await fetch(`/api/v1/queue/${queueId}/item_ids?order_dir=${order_dir}`);\n  if (res.status === 500) throw new Error((await res.json()).detail);\n  return await res.json();\n} catch (e) { console.error('item_ids failed:', e.message); return []; }","preventionTips":["Validate queue_id and order_dir before the call","Fetch queue ids from the queue list endpoint rather than hardcoding 'default'","Check DB permissions/locks if errors are persistent","Pin client to the matching InvokeAI API version"],"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"}