{"record":{"id":"dcece8532c943252","repo":"invoke-ai/InvokeAI","slug":"failed-to-get-queue-items","errorCode":null,"errorMessage":"Failed to get queue items","messagePattern":"Failed to get queue items","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"invokeai/app/api/routers/session_queue.py","lineNumber":235,"sourceCode":"        session_queue_service = ApiDependencies.invoker.services.session_queue\n\n        # Fetch queue items preserving the order of requested item ids\n        queue_items: list[SessionQueueItem] = []\n        for item_id in item_ids:\n            try:\n                queue_item = session_queue_service.get_queue_item(item_id=item_id)\n                if queue_item.queue_id != queue_id:  # Auth protection for items from other queues\n                    continue\n                # Sanitize item for non-admin users\n                sanitized_item = sanitize_queue_item_for_user(queue_item, current_user.user_id, current_user.is_admin)\n                queue_items.append(sanitized_item)\n            except Exception:\n                # Skip missing queue items - they may have been deleted between item id fetch and queue item fetch\n                continue\n\n        return queue_items\n    except Exception:\n        raise HTTPException(status_code=500, detail=\"Failed to get queue items\")\n\n\n@session_queue_router.post(\n    \"/{queue_id}/item_summaries_by_ids\",\n    operation_id=\"get_queue_item_summaries_by_ids\",\n    responses={200: {\"model\": list[SessionQueueItemSummary]}},\n)\ndef get_queue_item_summaries_by_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 summaries for\",\n    ),\n) -> list[SessionQueueItemSummary]:\n    \"\"\"Gets lightweight queue item summaries for specified IDs in requested order.\"\"\"\n    try:","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/api/routers/session_queue.py#L217-L253","documentation":"Generic 500 from get_queue_items_by_item_ids: unlike its siblings it does NOT interpolate the exception into the detail, so the response only says 'Failed to get queue items' and the real cause is lost to the client. The inner loop already tolerates items deleted between the id fetch and item fetch; anything else (invalid queue_id, DB failure) bubbles into this handler.","triggerScenarios":"POST /{queue_id}/items_by_ids with a bad queue_id, an item_ids payload the service cannot process, or a DB error; any per-item exception other than the tolerated 'missing item' case.","commonSituations":"Requesting ids that were just cancelled/deleted in bulk; passing item ids from a different queue than queue_id; heavy multiuser traffic causing sanitization or DB failures.","solutions":["Check server logs - the detail is static, so the traceback is only on the server","Re-fetch item ids via GET /{queue_id}/item_ids immediately before requesting items by id","Ensure all item_ids belong to the same queue_id used in the path","Reduce batch size / retry in case of transient DB issues"],"exampleFix":"// before: static detail hides the cause\nexcept Exception:\n    raise HTTPException(status_code=500, detail=\"Failed to get queue items\")\n// after: include cause for diagnosability\nexcept Exception as e:\n    raise HTTPException(status_code=500, detail=f\"Failed to get queue items: {e}\")","handlingStrategy":"try-catch","validationCode":"const ids = await (await fetch(`/api/v1/queue/${queueId}/item_ids`)).json();\nconst filtered = requestedIds.filter(id => ids.includes(id)); // only ask for ids that still exist","typeGuard":"function isQueueItems(v) { return Array.isArray(v) && v.every(i => i && typeof i === 'object' && 'session' in i); }","tryCatchPattern":"try {\n  const res = await fetch(`/api/v1/queue/${queueId}/items_by_ids`, {method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({item_ids: filtered})});\n  if (!res.ok) return []; // detail is static; check server logs for the cause\n  return await res.json();\n} catch { return []; }","preventionTips":["Re-fetch ids right before fetching items - items may be deleted concurrently","Only request ids belonging to the same queue_id in the path","Chunk large id lists to limit DB strain","Diagnose via server logs since the HTTP detail is static"],"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"}