invoke-ai/InvokeAI · error · HTTPException
Unexpected error while getting current queue item: {e}
Error message
Unexpected error while getting current queue item: {e} What it means
Catch-all 500 for get_current_queue_item: exceptions from session_queue.get_current() (or the subsequent sanitize_queue_item_for_user call) are wrapped as HTTP 500. The route returns the currently executing queue item or null if the queue is idle.
Source
Thrown at invokeai/app/api/routers/session_queue.py:485
@session_queue_router.get(
"/{queue_id}/current",
operation_id="get_current_queue_item",
responses={
200: {"model": Optional[SessionQueueItem]},
},
)
def get_current_queue_item(
current_user: CurrentUserOrDefault,
queue_id: str = Path(description="The queue id to perform this operation on"),
) -> Optional[SessionQueueItem]:
"""Gets the currently execution queue item"""
try:
item = ApiDependencies.invoker.services.session_queue.get_current(queue_id)
if item is not None:
item = sanitize_queue_item_for_user(item, current_user.user_id, current_user.is_admin)
return item
except Exception as e:
raise HTTPException(status_code=500, detail=f"Unexpected error while getting current queue item: {e}")
@session_queue_router.get(
"/{queue_id}/next",
operation_id="get_next_queue_item",
responses={
200: {"model": Optional[SessionQueueItem]},
},
)
def get_next_queue_item(
current_user: CurrentUserOrDefault,
queue_id: str = Path(description="The queue id to perform this operation on"),
) -> Optional[SessionQueueItem]:
"""Gets the next queue item, without executing it"""
try:
item = ApiDependencies.invoker.services.session_queue.get_next(queue_id)
if item is not None:
item = sanitize_queue_item_for_user(item, current_user.user_id, current_user.is_admin)View on GitHub (pinned to 0b6a024f2f)
Solutions
- Read the {e} detail and server traceback for the root cause.
- Verify queue_id via GET status and confirm DB health.
- Treat null result as 'queue idle' in clients rather than retrying aggressively.
- Upgrade/restart InvokeAI if the traceback indicates corrupted item data or a service bug.
Example fix
// before: assuming data on every poll
item = requests.get(f"{base}/api/v1/queue/{queue_id}/current").json()
process(item)
// after: handle idle queue
resp = requests.get(f"{base}/api/v1/queue/{queue_id}/current")
item = resp.json() if resp.ok else None
if item is not None:
process(item) Defensive patterns
Strategy: try-catch
Validate before calling
const status = await fetch(`${base}/api/v1/queue/${queueId}/status`);
if (!status.ok) throw new Error(`queue ${queueId} unknown`); Type guard
function isQueueItemOrNull(v) {
return v === null || (typeof v === 'object' && v !== null && 'item_id' in v && 'queue_id' in v);
} Try / catch
try {
const r = await fetch(`${base}/api/v1/queue/${queueId}/current`);
if (!r.ok) throw new Error((await r.json()).detail);
const item = await r.json(); // null means queue is idle
if (item) updateProgress(item);
} catch (e) {
await sleep(backoff); // don't hammer a failing service
} Prevention
- Treat null as idle, not as an error condition
- Poll with backoff to avoid DB contention
- Validate queue_id before polling
- Keep server and schema versions aligned
When it happens
Trigger: GET /api/v1/queue/{queue_id}/current when the service call raises (DB failure, unknown queue) or sanitization throws on malformed item data.
Common situations: DB locked/down; queue_id typo; corrupted queue item row causing sanitize failures; service not initialized after partial startup.
Related errors
- Unexpected error while getting next queue item: {e}
- 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
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/bc1c6004c5354a0f.
Report an issue: GitHub.