invoke-ai/InvokeAI · error · HTTPException

Unexpected error while listing all queue item ids: {e}

Error message

Unexpected error while listing all queue item ids: {e}

What it means

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.

Source

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

def get_queue_item_ids(
    current_user: CurrentUserOrDefault,
    queue_id: str = Path(description="The queue id to perform this operation on"),
    order_dir: SQLiteDirection = Query(default=SQLiteDirection.Descending, description="The order of sort"),
) -> ItemIdsResult:
    """Gets all queue item ids that match the given parameters.

    IDs for every user's items are returned (item ids carry no sensitive data on their own).
    When the corresponding items are hydrated via get_queue_items_by_item_ids, those belonging
    to other users are redacted by sanitize_queue_item_for_user. This lets a non-admin see
    partially-redacted entries for other users' jobs in the queue list, while still revealing
    only timestamps and status for items they do not own.

    current_user is required so the endpoint stays behind authentication in multiuser mode.
    """
    try:
        return ApiDependencies.invoker.services.session_queue.get_queue_item_ids(queue_id=queue_id, order_dir=order_dir)
    except Exception as e:
        raise HTTPException(status_code=500, detail=f"Unexpected error while listing all queue item ids: {e}")


@session_queue_router.post(
    "/{queue_id}/items_by_ids",
    operation_id="get_queue_items_by_item_ids",
    responses={200: {"model": list[SessionQueueItem]}},
)
def get_queue_items_by_item_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 queue items for",
    ),
) -> list[SessionQueueItem]:
    """Gets queue items for the specified queue item ids. Maintains order of item ids.

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Check the detail message for the underlying exception
  2. Validate queue_id against GET /queue/{queue_id} or list of queues before calling
  3. Use a supported order_dir value ('ASC'/'DESC') for your InvokeAI version
  4. Investigate DB errors (locked file, permissions) if the message points at sqlite

Example fix

// before
GET /api/v1/queue/wrong-queue-id/item_ids  // 500
// after
const q = await fetch('/api/v1/queue/wrong-queue-id');
if (q.ok) await fetch('/api/v1/queue/wrong-queue-id/item_ids');
Defensive patterns

Strategy: validation

Validate before calling

const q = await fetch(`/api/v1/queue/${queueId}`);
if (!q.ok) throw new Error(`Queue ${queueId} not found`);
if (!['ASC','DESC'].includes(order_dir)) throw new Error(`Invalid order_dir: ${order_dir}`);

Type guard

function isItemIdList(v) { return Array.isArray(v) && v.every(n => typeof n === 'number' || typeof n === 'string'); }

Try / catch

try {
  const res = await fetch(`/api/v1/queue/${queueId}/item_ids?order_dir=${order_dir}`);
  if (res.status === 500) throw new Error((await res.json()).detail);
  return await res.json();
} catch (e) { console.error('item_ids failed:', e.message); return []; }

Prevention

When it happens

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

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

Related errors


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