invoke-ai/InvokeAI · error · HTTPException
Unexpected error while canceling all except current: {e}
Error message
Unexpected error while canceling all except current: {e} What it means
Thrown by cancel_all_except_current: any exception from SessionQueue.cancel_all_except_current(queue_id, user_id) becomes a 500 with the exception message in the detail. Non-admin users are scoped to their own items via user_id; failures here are unclassified and reported as generic server errors.
Source
Thrown at invokeai/app/api/routers/session_queue.py:311
@session_queue_router.put(
"/{queue_id}/cancel_all_except_current",
operation_id="cancel_all_except_current",
responses={200: {"model": CancelAllExceptCurrentResult}},
)
def cancel_all_except_current(
current_user: CurrentUserOrDefault,
queue_id: str = Path(description="The queue id to perform this operation on"),
) -> CancelAllExceptCurrentResult:
"""Immediately cancels all queue items except in-processing items. Non-admin users can only cancel their own items."""
try:
# Admin users can cancel all items, non-admin users can only cancel their own
user_id = None if current_user.is_admin else current_user.user_id
return ApiDependencies.invoker.services.session_queue.cancel_all_except_current(
queue_id=queue_id, user_id=user_id
)
except Exception as e:
raise HTTPException(status_code=500, detail=f"Unexpected error while canceling all except current: {e}")
@session_queue_router.put(
"/{queue_id}/delete_all_except_current",
operation_id="delete_all_except_current",
responses={200: {"model": DeleteAllExceptCurrentResult}},
)
def delete_all_except_current(
current_user: CurrentUserOrDefault,
queue_id: str = Path(description="The queue id to perform this operation on"),
) -> DeleteAllExceptCurrentResult:
"""Immediately deletes all queue items except in-processing items. Non-admin users can only delete their own items."""
try:
# Admin users can delete all items, non-admin users can only delete their own
user_id = None if current_user.is_admin else current_user.user_id
return ApiDependencies.invoker.services.session_queue.delete_all_except_current(
queue_id=queue_id, user_id=user_id
)View on GitHub (pinned to 0b6a024f2f)
Solutions
- Check detail string for the underlying exception
- Verify queue_id is valid on the current instance
- Retry during lower load if SQLite locking is implicated
- If persistent, check server logs and DB integrity (integrity_check on invokeai.db)
Defensive patterns
Strategy: try-catch
Validate before calling
const q = await fetch(`/api/v1/queue/${queueId}`);
if (!q.ok) throw new Error(`Queue ${queueId} not found`); Type guard
function isCancelResult(v) { return v !== null && typeof v === 'object' && 'canceled' in v; } Try / catch
try {
const res = await fetch(`/api/v1/queue/${queueId}/cancel_all_except_current`, {method:'PUT'});
if (res.status === 500) throw new Error((await res.json()).detail);
return await res.json();
} catch (e) { console.error('bulk cancel failed:', e.message); } Prevention
- Validate queue_id before bulk operations
- Avoid bulk cancel during heavy queue writes; pause first if needed
- Read the detail string - the underlying exception is embedded
- Run DB integrity checks if cancel failures recur
When it happens
Trigger: PUT /{queue_id}/cancel_all_except_current with an invalid queue_id, DB write failure during bulk cancel, or an internal service error while computing cancellable items.
Common situations: Bulk-cancel while the queue is under heavy write load (SQLite lock contention); stale queue_id after switching instances; admin flag not set so scoping logic operates on unexpected user data.
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/38f85f6123988534.
Report an issue: GitHub.