invoke-ai/InvokeAI · error · HTTPException

Failed to get queue items

Error message

Failed to get queue items

What it means

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.

Source

Thrown at invokeai/app/api/routers/session_queue.py:235

        session_queue_service = ApiDependencies.invoker.services.session_queue

        # Fetch queue items preserving the order of requested item ids
        queue_items: list[SessionQueueItem] = []
        for item_id in item_ids:
            try:
                queue_item = session_queue_service.get_queue_item(item_id=item_id)
                if queue_item.queue_id != queue_id:  # Auth protection for items from other queues
                    continue
                # Sanitize item for non-admin users
                sanitized_item = sanitize_queue_item_for_user(queue_item, current_user.user_id, current_user.is_admin)
                queue_items.append(sanitized_item)
            except Exception:
                # Skip missing queue items - they may have been deleted between item id fetch and queue item fetch
                continue

        return queue_items
    except Exception:
        raise HTTPException(status_code=500, detail="Failed to get queue items")


@session_queue_router.post(
    "/{queue_id}/item_summaries_by_ids",
    operation_id="get_queue_item_summaries_by_ids",
    responses={200: {"model": list[SessionQueueItemSummary]}},
)
def get_queue_item_summaries_by_ids(
    current_user: CurrentUserOrDefault,
    queue_id: str = Path(description="The queue id to perform this operation on"),
    item_ids: list[int] = Body(
        embed=True,
        max_length=MAX_QUEUE_ITEM_IDS_PER_REQUEST,
        description="Object containing list of queue item ids to fetch summaries for",
    ),
) -> list[SessionQueueItemSummary]:
    """Gets lightweight queue item summaries for specified IDs in requested order."""
    try:

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Check server logs - the detail is static, so the traceback is only on the server
  2. Re-fetch item ids via GET /{queue_id}/item_ids immediately before requesting items by id
  3. Ensure all item_ids belong to the same queue_id used in the path
  4. Reduce batch size / retry in case of transient DB issues

Example fix

// before: static detail hides the cause
except Exception:
    raise HTTPException(status_code=500, detail="Failed to get queue items")
// after: include cause for diagnosability
except Exception as e:
    raise HTTPException(status_code=500, detail=f"Failed to get queue items: {e}")
Defensive patterns

Strategy: try-catch

Validate before calling

const ids = await (await fetch(`/api/v1/queue/${queueId}/item_ids`)).json();
const filtered = requestedIds.filter(id => ids.includes(id)); // only ask for ids that still exist

Type guard

function isQueueItems(v) { return Array.isArray(v) && v.every(i => i && typeof i === 'object' && 'session' in i); }

Try / catch

try {
  const res = await fetch(`/api/v1/queue/${queueId}/items_by_ids`, {method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({item_ids: filtered})});
  if (!res.ok) return []; // detail is static; check server logs for the cause
  return await res.json();
} catch { return []; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/dcece8532c943252. Report an issue: GitHub.