invoke-ai/InvokeAI · error · HTTPException
Unexpected error while canceling by destination: {e}
Error message
Unexpected error while canceling by destination: {e} What it means
Same catch-all 500 pattern as the batch-cancel route, but for cancel_by_destination: any exception from the session queue service while canceling items by destination id is converted into HTTP 500 with the original message appended. The destination parameter identifies the node destination whose items should be canceled.
Source
Thrown at invokeai/app/api/routers/session_queue.py:373
@session_queue_router.put(
"/{queue_id}/cancel_by_destination",
operation_id="cancel_by_destination",
responses={200: {"model": CancelByDestinationResult}},
)
def cancel_by_destination(
current_user: CurrentUserOrDefault,
queue_id: str = Path(description="The queue id to perform this operation on"),
destination: str = Query(description="The destination to cancel all queue items for"),
) -> CancelByDestinationResult:
"""Immediately cancels all queue items with the given destination. 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_by_destination(
queue_id=queue_id, destination=destination, user_id=user_id
)
except Exception as e:
raise HTTPException(status_code=500, detail=f"Unexpected error while canceling by destination: {e}")
@session_queue_router.put(
"/{queue_id}/retry_items_by_id",
operation_id="retry_items_by_id",
responses={200: {"model": RetryItemsResult}},
)
def retry_items_by_id(
current_user: CurrentUserOrDefault,
queue_id: str = Path(description="The queue id to perform this operation on"),
item_ids: list[int] = Body(description="The queue item ids to retry"),
) -> RetryItemsResult:
"""Retries the given queue items. Users can only retry their own items unless they are an admin."""
try:
# Check queue membership for all items and ownership for non-admins.
valid_item_ids: list[int] = []
for item_id in item_ids:
try:View on GitHub (pinned to 0b6a024f2f)
Solutions
- Read the {e} text in the response detail plus server traceback for the root cause.
- Validate the destination exists in the currently queued items (query queue items and inspect destination fields) before canceling.
- Check database health and migrations as for other queue 500s.
- Retry once after transient DB lock errors; otherwise fix the underlying DB/service condition.
Example fix
// before: blind cancel by destination
requests.put(f"{base}/api/v1/queue/{queue_id}/cancel_by_destination", json={"destination": dest})
// after: verify destination is present in queue first
items = requests.get(f"{base}/api/v1/queue/{queue_id}/items").json()["items"]
if any(i["destination"] == dest for i in items):
requests.put(f"{base}/api/v1/queue/{queue_id}/cancel_by_destination", json={"destination": dest}) Defensive patterns
Strategy: validation
Validate before calling
const items = (await fetch(`${base}/api/v1/queue/${queueId}/items`).then(r => r.json())).items;
if (!items.some(i => i.destination === destination)) {
throw new Error(`destination ${destination} has no queued items`);
} Type guard
function hasItemsAtDestination(items, destination) {
return Array.isArray(items) && items.some(i => i?.destination === destination);
} Try / catch
try {
const r = await fetch(url, { method: 'PUT', body: JSON.stringify({ destination }) });
if (!r.ok) throw new Error((await r.json()).detail);
} catch (e) {
logger.error(`cancel_by_destination failed: ${e.message}`);
} Prevention
- Validate the destination exists among queued items first
- Avoid typo'd destination names — derive them from graph definitions
- Monitor DB lock errors during heavy queue churn
- Re-check destinations after server upgrades/schema changes
When it happens
Trigger: PUT /api/v1/queue/{queue_id}/cancel_by_destination with a destination string, when the underlying service call raises (DB failure, unknown destination, service-layer bug).
Common situations: Passing a destination id that no session/graph references; DB locked or down; server upgraded with schema mismatch; typo'd destination name from a workflow.
Related errors
- Unexpected error while canceling by batch id: {e}
- Unexpected error while clearing queue: {e}
- Unexpected error while pruning queue: {e}
- Unexpected error while getting queue status: {e}
- Unexpected error while getting batch status: {e}
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/666ce06299ef4af7.
Report an issue: GitHub.