invoke-ai/InvokeAI · error · HTTPException
Unexpected error while retrying queue items: {e}
Error message
Unexpected error while retrying queue items: {e} What it means
Catch-all 500 for retry_items_by_id: after the per-item validation loop, any exception from session_queue.retry_items_by_id() is wrapped as HTTP 500 with the original error text appended. HTTPExceptions raised during validation are re-raised unchanged (see the preceding except HTTPException: raise).
Source
Thrown at invokeai/app/api/routers/session_queue.py:417
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_ids
)
except HTTPException:
raise
except Exception as e:
raise HTTPException(status_code=500, detail=f"Unexpected error while retrying queue items: {e}")
@session_queue_router.put(
"/{queue_id}/clear",
operation_id="clear",
responses={
200: {"model": ClearResult},
},
)
def clear(
current_user: CurrentUserOrDefault,
queue_id: str = Path(description="The queue id to perform this operation on"),
) -> ClearResult:
"""Clears the queue. Admin users clear (and cancel) all items; non-admin users clear only their
own items — other users' queued and running items are untouched."""
try:
# The service cancels every in-progress item in scope itself (there can be several
# with multiple workers), so there is no per-item authorization to do here: aView on GitHub (pinned to 0b6a024f2f)
Solutions
- Inspect the appended {e} message and server traceback for the root cause.
- Check DB health and pending migrations.
- Confirm the queue still exists and items were not pruned between validation and retry.
- Retry after transient DB errors; upgrade InvokeAI if the traceback points at service internals.
Example fix
// before: no error discrimination
resp = requests.put(url, json={"item_ids": ids})
// after: retry once on transient failure
resp = requests.put(url, json={"item_ids": ids})
if resp.status_code == 500 and 'locked' in resp.json().get('detail', ''):
time.sleep(1); resp = requests.put(url, json={"item_ids": ids}) Defensive patterns
Strategy: retry
Validate before calling
const valid = [];
for (const id of ids) {
const item = await fetch(`${base}/api/v1/queue/items/${id}`).then(r => r.ok ? r.json() : null);
if (item && item.queue_id === queueId) valid.push(id);
}
if (valid.length === 0) return; // nothing to retry Type guard
function isRetryableItemsResult(v): v is { retried_item_ids: number[] } {
return typeof v === 'object' && v !== null && 'retried_item_ids' in v;
} Try / catch
for (let attempt = 0; attempt < 3; attempt++) {
const r = await fetch(url, { method: 'PUT', body: JSON.stringify({ item_ids: valid }) });
if (r.ok) break;
const detail = (await r.json()).detail ?? '';
if (/locked|database/i.test(detail)) await sleep(1000 * (attempt + 1));
else throw new Error(`retry_items_by_id failed: ${detail}`);
} Prevention
- Pre-validate items exist in the queue before retry
- Use bounded retry with backoff for transient DB errors
- Keep queue service and DB schema in sync across upgrades
- Inspect the wrapped detail string for root cause
When it happens
Trigger: PUT retry_items_by_id with valid_item_ids non-empty, when the service-layer retry call raises (DB error, constraint violation, service bug, empty valid list hitting service assumptions).
Common situations: DB locked/down; retrying an item whose session data was pruned; server upgrade with schema drift; internal service bugs when re-enqueueing graph sessions.
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/f6d109add27339a2.
Report an issue: GitHub.