invoke-ai/InvokeAI · error · HTTPException

You do not have permission to cancel this queue item

Error message

You do not have permission to cancel this queue item

What it means

This HTTP 403 is raised when an authenticated user attempts to cancel a queue item they do not own and their token does not carry the is_admin flag. InvokeAI's multi-user mode scopes queue items to the user_id that enqueued them, and only admins may cancel other users' items. The check happens after the 404 queue-match check and before the service call.

Source

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

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

        # Check authorization: user must own the item or be an admin
        if 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 cancel this queue item")

        return ApiDependencies.invoker.services.session_queue.cancel_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 canceling queue item: {e}")


@session_queue_router.get(
    "/{queue_id}/counts_by_destination",
    operation_id="counts_by_destination",
    responses={200: {"model": SessionQueueCountsByDestination}},
)
def counts_by_destination(
    current_user: CurrentUserOrDefault,
    queue_id: str = Path(description="The queue id to query"),

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Cancel the item with the same user account that enqueued it
  2. Have an admin user (is_admin=true token) perform the cancellation
  3. Re-login or re-issue the token if the user was recently promoted to admin (stale TokenData)
  4. Enable anonymous/admin single-user mode if per-user isolation is not needed for your deployment

Example fix

// before
// cancelling with a regular user token an item owned by someone else
await api.delete(`/session_queue/${queueId}/i/${itemId}`);
// after
// run as admin token or the owning user
const item = await api.get(`/session_queue/${queueId}/i/${itemId}`);
if (item.user_id === currentUser.id || currentUser.is_admin) {
  await api.delete(`/session_queue/${queueId}/i/${itemId}`);
}
Defensive patterns

Strategy: try-catch

Validate before calling

const item = await api.get(`/session_queue/${queueId}/i/${itemId}`);
if (item.data.user_id !== currentUser.id && !currentUser.is_admin) {
  throw new Error('Current user cannot cancel this item; use the owning user or an admin token');
}

Type guard

function canCancel(item, user) {
  return user.is_admin === true || item.user_id === user.user_id;
}

Try / catch

try {
  await api.delete(`/session_queue/${queueId}/i/${itemId}`);
} catch (e) {
  if (e.response?.status === 403) {
    console.warn('Not your queue item; request an admin to cancel it');
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling the cancel endpoint as a non-admin user where queue_item.user_id differs from current_user.user_id — e.g. cancelling another user's queued generation.

Common situations: Shared/multi-user InvokeAI instances where a user grabs an item ID from logs or another user's UI; service accounts with non-admin tokens trying to manage items enqueued by other accounts; tokens issued before the user was promoted to admin still cached client-side.

Related errors


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