invoke-ai/InvokeAI · error · HTTPException

Unexpected error while deleting queue item: {e}

Error message

Unexpected error while deleting queue item: {e}

What it means

HTTPException(500) catch-all in DELETE /session_queue/{queue_id}/i/{item_id} for any exception other than item-not-found, explicit HTTPExceptions, or other handled types. Failures in the delete_queue_item service call (DB errors, event-bus broadcast failures while notifying queue listeners) surface as this generic 500.

Source

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

        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}")

        # The queue service deletes the entire chain, so authorization must use the root owner.
        if root_queue_item.user_id != current_user.user_id and not current_user.is_admin:
            raise HTTPException(status_code=403, detail="You do not have permission to delete this queue item")

        ApiDependencies.invoker.services.session_queue.delete_queue_item(item_id)
    except SessionQueueItemNotFoundError:
        raise HTTPException(status_code=404, detail=f"Queue item with id {item_id} not found in queue {queue_id}")
    except HTTPException:
        raise
    except Exception as e:
        raise HTTPException(status_code=500, detail=f"Unexpected error while deleting queue item: {e}")


@session_queue_router.put(
    "/{queue_id}/i/{item_id}/cancel",
    operation_id="cancel_queue_item",
    responses={
        200: {"model": SessionQueueItem},
    },
)
def cancel_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 cancel"),
) -> SessionQueueItem:
    """Cancels a queue item. Users can only cancel their own items unless they are an admin."""
    try:
        # Get the queue item to check ownership
        queue_item = ApiDependencies.invoker.services.session_queue.get_queue_item(item_id)

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Inspect the interpolated {e} in the detail and the server logs for the root cause
  2. Check DB connectivity/locks and retry the delete once storage is healthy
  3. Restart the API server if the event bus or service graph is in a bad state
  4. If deletion keeps failing for one chain, try cancelling then deleting, or remove via DB maintenance tooling

Example fix

// before: single DELETE fails transiently
await api.delete(`/api/v1/session_queue/${queueId}/i/${itemId}`)
// after: retry transient 500s
await retry(async () => api.delete(...), { retries: 2, retryOn: [500, 503] })
Defensive patterns

Strategy: retry

Validate before calling

// quick health check before delete
const health = await fetch('/api/v1/session_queue/status')
if (!health.ok) throw new Error('Queue backend unhealthy; postpone delete')

Try / catch

try {
  await api.delete(`/api/v1/session_queue/${queueId}/i/${itemId}`)
} catch (e) {
  if (e.response?.status === 500) {
    log.error('Delete failed:', e.response.data?.detail)
    await retry(() => api.delete(...), { retries: 2, backoff: 'exponential' })
  } else throw e
}

Prevention

When it happens

Trigger: Calling DELETE when the underlying delete_queue_item throws: database write failure, the events service cannot publish queue-item-deleted, or an unexpected error inside chain deletion of a workflow-call chain.

Common situations: SQLite database locked by another process (e.g. a backup or another InvokeAI process); DB connection pool exhausted under load; event bus (WebSocket) service in a bad state after a partial restart.

Related errors


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