invoke-ai/InvokeAI · error · HTTPException
Queue item with id {item_id} not found in queue {queue_id}
Error message
Queue item with id {item_id} not found in queue {queue_id} What it means
A 404 raised by retry_items_by_id when a requested queue item exists but belongs to a different queue than the path's queue_id — either the item itself or its workflow-call root item is in another queue. The API treats cross-queue access as 'not found' in this queue rather than leaking membership.
Source
Thrown at invokeai/app/api/routers/session_queue.py:394
@session_queue_router.put(
"/{queue_id}/retry_items_by_id",
operation_id="retry_items_by_id",
responses={200: {"model": RetryItemsResult}},
)
def retry_items_by_id(
current_user: CurrentUserOrDefault,
queue_id: str = Path(description="The queue id to perform this operation on"),
item_ids: list[int] = Body(description="The queue item ids to retry"),
) -> RetryItemsResult:
"""Retries the given queue items. Users can only retry their own items unless they are an admin."""
try:
# Check queue membership for all items and ownership for non-admins.
valid_item_ids: list[int] = []
for item_id in item_ids:
try:
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}"
)
root_queue_item = _get_workflow_call_root_queue_item(queue_item)
if root_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}"
)
if not current_user.is_admin and root_queue_item.user_id != current_user.user_id:
raise HTTPException(
status_code=403, detail=f"You do not have permission to retry queue item {item_id}"
)
valid_item_ids.append(item_id)
except SessionQueueItemNotFoundError:
# Skip items that don't exist - they will be handled by retry_items_by_id
continue
return ApiDependencies.invoker.services.session_queue.retry_items_by_id(
queue_id=queue_id, item_ids=valid_item_idsView on GitHub (pinned to 0b6a024f2f)
Solutions
- Fetch the item first (GET queue item) and confirm its queue_id matches the path queue_id before retrying.
- List current queue items to obtain fresh, valid ids for the target queue.
- Fix the client to track (queue_id, item_id) pairs together instead of bare ids.
- If ids come from persisted bookmarks, validate them against the queue on startup and prune stale ones.
Example fix
// before
requests.put(f"{base}/api/v1/queue/{queue_id}/retry_items_by_id", json={"item_ids": [42]})
// after
item = requests.get(f"{base}/api/v1/queue/items/42").json()
if item["queue_id"] == queue_id:
requests.put(f"{base}/api/v1/queue/{queue_id}/retry_items_by_id", json={"item_ids": [42]}) Defensive patterns
Strategy: validation
Validate before calling
const item = await fetch(`${base}/api/v1/queue/items/${itemId}`).then(r => r.json());
if (item.queue_id !== queueId) throw new Error(`item ${itemId} is in queue ${item.queue_id}, not ${queueId}`); Type guard
function belongsToQueue(item, queueId) {
return item != null && item.queue_id === queueId;
} Try / catch
try {
const r = await fetch(`${base}/api/v1/queue/${queueId}/retry_items_by_id`, { method: 'PUT', body: JSON.stringify({ item_ids: ids }) });
if (r.status === 404) {
const detail = (await r.json()).detail;
console.warn('stale item id:', detail);
ids = ids.filter(i => !detail.includes(`id ${i} `));
}
} catch (e) { /* handle */ } Prevention
- Track (queue_id, item_id) pairs, never bare ids
- Refresh item ids after clearing/creating queues
- Verify item queue membership before retry
- Prune stale persisted ids against the live queue
When it happens
Trigger: PUT /api/v1/queue/{queue_id}/retry_items_by_id with an item_ids entry whose queue_item.queue_id (or its root queue item's queue_id) does not match the path queue_id.
Common situations: Client caches item ids from a previous queue after clearing/creating a new queue; retrying an id against the wrong queue id; workflow-call chains whose root item lives in a different queue.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Image not found
- Board not found
- No external provider config fields provided
- Unknown external provider '{provider_id}'
- User not found
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/f2ef542b12e5e43a.
Report an issue: GitHub.