invoke-ai/InvokeAI · error · HTTPException
Unexpected error while fetching queue item: {e}
Error message
Unexpected error while fetching queue item: {e} What it means
HTTPException(500) raised as the catch-all in GET /session_queue/{queue_id}/i/{item_id} when any exception other than the queue-id mismatch or SessionQueueItemNotFoundError occurs while fetching or sanitizing the item. This includes sanitize_queue_item_for_user failures and service/storage errors.
Source
Thrown at invokeai/app/api/routers/session_queue.py:579
},
response_model_exclude_none=True,
)
def get_queue_item(
current_user: CurrentUserOrDefault,
queue_id: str = Path(description="The queue id to perform this operation on"),
item_id: int = Path(description="The queue item to get"),
) -> SessionQueueItem:
"""Gets a queue item"""
try:
queue_item = ApiDependencies.invoker.services.session_queue.get_queue_item(item_id=item_id)
if queue_item.queue_id != queue_id:
raise HTTPException(status_code=404, detail=f"Queue item with id {item_id} not found in queue {queue_id}")
# Sanitize item for non-admin users
return sanitize_queue_item_for_user(queue_item, current_user.user_id, current_user.is_admin)
except SessionQueueItemNotFoundError:
raise HTTPException(status_code=404, detail=f"Queue item with id {item_id} not found in queue {queue_id}")
except Exception as e:
raise HTTPException(status_code=500, detail=f"Unexpected error while fetching queue item: {e}")
@session_queue_router.delete(
"/{queue_id}/i/{item_id}",
operation_id="delete_queue_item",
)
def delete_queue_item(
current_user: CurrentUserOrDefault,
queue_id: str = Path(description="The queue id to perform this operation on"),
item_id: int = Path(description="The queue item to delete"),
) -> None:
"""Deletes a queue item. Users can only delete their own items unless they are an admin."""
try:
# Get the queue item to check ownership
queue_item = ApiDependencies.invoker.services.session_queue.get_queue_item(item_id)
if queue_item.queue_id != queue_id:
raise HTTPException(status_code=404, detail=f"Queue item with id {item_id} not found in queue {queue_id}")
View on GitHub (pinned to 0b6a024f2f)
Solutions
- Inspect the interpolated {e} in the response detail and server logs to find the failing step
- If sanitization/graph deserialization is the cause, delete the corrupted queue item via the queue UI/API and re-run the generation
- Check database health and re-run migrations after upgrades
- Retry after a transient DB error is resolved
Example fix
// before: 500 on malformed stored graph
GET /api/v1/session_queue/q1/i/42
// after: catch and fall back to listing items
try { return await getItem(queueId, itemId) }
catch (e) { log.warn(e); return (await listItems(queueId)).find(i => i.item_id === itemId) ?? null } Defensive patterns
Strategy: fallback
Validate before calling
// fall back to listing if direct fetch returns 500
try { return await api.get(`/api/v1/session_queue/${queueId}/i/${itemId}`) }
catch { /* handled below */ } Type guard
function isWellFormedQueueItem(item) {
return item != null && typeof item.item_id === 'number' && item.session != null
} Try / catch
try {
return await api.get(`/api/v1/session_queue/${queueId}/i/${itemId}`)
} catch (e) {
if (e.response?.status === 500) {
log.error('Queue item fetch failed:', e.response.data?.detail)
return (await api.get(`/api/v1/session_queue/${queueId}/items`)).data.items.find(i => i.item_id === itemId) ?? null
}
throw e
} Prevention
- Check server logs for graph/serialization errors on stored queue items
- Delete and re-enqueue corrupted items rather than retrying them
- Keep DB healthy and upgraded to the schema matching your InvokeAI version
When it happens
Trigger: Calling GET /api/v1/session_queue/{queue_id}/i/{item_id} when the underlying get_queue_item service call throws a non-not-found error (DB failure), or sanitize_queue_item_for_user raises while stripping data for a non-admin user (e.g. malformed session graph JSON stored on the item).
Common situations: Corrupted queue item row whose session/graph payload fails to deserialize; database outage; a non-admin user requesting an item whose stored graph trips the sanitization code.
Related errors
- Unexpected error while enqueuing batch: {e}
- Unexpected error while listing all queue items: {e}
- Unexpected error while listing all queue item ids: {e}
- Failed to get queue items
- Failed to get queue item summaries
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/df75f545e40b3f8f.
Report an issue: GitHub.