invoke-ai/InvokeAI · error · HTTPException
Unexpected error while getting batch status: {e}
Error message
Unexpected error while getting batch status: {e} What it means
HTTPException(500) raised by the GET /session_queue/{queue_id}/b/{batch_id}/status endpoint when ApiDependencies.invoker.services.session_queue.get_batch_status() throws any unhandled exception. The endpoint simply delegates to the queue service (scoping to the caller's user_id unless admin), so any storage or service-layer failure surfaces as this generic 500.
Source
Thrown at invokeai/app/api/routers/session_queue.py:553
"/{queue_id}/b/{batch_id}/status",
operation_id="get_batch_status",
responses={
200: {"model": BatchStatus},
},
)
def get_batch_status(
current_user: CurrentUserOrDefault,
queue_id: str = Path(description="The queue id to perform this operation on"),
batch_id: str = Path(description="The batch to get the status of"),
) -> BatchStatus:
"""Gets the status of a batch. Non-admin users only see their own batches."""
try:
user_id = None if current_user.is_admin else current_user.user_id
return ApiDependencies.invoker.services.session_queue.get_batch_status(
queue_id=queue_id, batch_id=batch_id, user_id=user_id
)
except Exception as e:
raise HTTPException(status_code=500, detail=f"Unexpected error while getting batch status: {e}")
@session_queue_router.get(
"/{queue_id}/i/{item_id}",
operation_id="get_queue_item",
responses={
200: {"model": SessionQueueItem},
},
response_model_exclude_none=True,
)
def get_queue_item(
current_user: CurrentUserOrDefault,
queue_id: str = Path(description="The queue id to perform this operation on"),
item_id: int = Path(description="The queue item to get"),
) -> SessionQueueItem:
"""Gets a queue item"""
try:
queue_item = ApiDependencies.invoker.services.session_queue.get_queue_item(item_id=item_id)View on GitHub (pinned to 0b6a024f2f)
Solutions
- Read the interpolated {e} in the response detail to identify the underlying exception
- Check database connectivity and lock contention on the queue store
- Verify the batch_id exists (list batches via the queue status endpoint) and matches the queue_id
- Re-run DB migrations if the schema was changed by an upgrade
Example fix
// before
const status = await fetch(`/api/v1/session_queue/${queueId}/b/${batchId}/status`)
// after: validate batch exists before fetching full status
const batches = await getQueueBatches(queueId)
if (!batches.some(b => b.batch_id === batchId)) throw new Error(`Batch ${batchId} not in queue ${queueId}`) Defensive patterns
Strategy: try-catch
Validate before calling
// verify batch exists before requesting status
const queue = await api.get(`/api/v1/session_queue/${queueId}/status`)
if (!queue.data.queue.batches.some(b => b.batch_id === batchId)) {
throw new Error(`Batch ${batchId} not present in queue ${queueId}`)
} Try / catch
try {
return await api.get(`/api/v1/session_queue/${queueId}/b/${batchId}/status`)
} catch (e) {
if (e.response?.status === 500) { log.warn(e.response.data?.detail); return null }
throw e
} Prevention
- Validate batch_id against the queue's batch list before querying
- Check DB health/lock state during heavy queue usage
- Re-run migrations after InvokeAI upgrades
When it happens
Trigger: Calling GET /api/v1/session_queue/{queue_id}/b/{batch_id}/status when get_batch_status raises: batch row corrupt, DB connection dropped, or an invalid batch_id type slipping past validation into the service.
Common situations: Database unavailable or locked (SQLite lock contention during heavy queue usage); version upgrade left the batches table missing; passing a batch_id that was deleted concurrently.
Related errors
- Unexpected error while canceling by batch id: {e}
- Unexpected error while canceling by destination: {e}
- Unexpected error while clearing queue: {e}
- Unexpected error while pruning queue: {e}
- Unexpected error while getting queue status: {e}
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/0086ad6c618ca4ae.
Report an issue: GitHub.