invoke-ai/InvokeAI · error
Default workflows cannot be deleted
Error message
Default workflows cannot be deleted
What it means
delete() checks the stored workflow's category first (via self.get) and refuses to delete Default-category workflows. This protects built-in workflows shipped with the application from being removed by user actions.
Source
Thrown at invokeai/app/services/workflow_records/workflow_records_sqlite.py:103
SET workflow = ?
WHERE workflow_id = ? AND category = 'user' AND user_id = ?;
""",
(workflow.model_dump_json(), workflow.id, user_id),
)
else:
cursor.execute(
"""--sql
UPDATE workflow_library
SET workflow = ?
WHERE workflow_id = ? AND category = 'user';
""",
(workflow.model_dump_json(), workflow.id),
)
return self.get(workflow.id)
def delete(self, workflow_id: str, user_id: Optional[str] = None) -> None:
if self.get(workflow_id).workflow.meta.category is WorkflowCategory.Default:
raise ValueError("Default workflows cannot be deleted")
with self._db.transaction() as cursor:
if user_id is not None:
cursor.execute(
"""--sql
DELETE from workflow_library
WHERE workflow_id = ? AND category = 'user' AND user_id = ?;
""",
(workflow_id, user_id),
)
else:
cursor.execute(
"""--sql
DELETE from workflow_library
WHERE workflow_id = ? AND category = 'user';
""",
(workflow_id,),
)View on GitHub (pinned to 0b6a024f2f)
Solutions
- Only delete Custom-category workflows; filter the id list before calling delete
- Catch ValueError per id in batch deletes and log skips for defaults
- If the default workflow must go away, it should be removed in the app's default-workflow definitions/sync, not via delete()
Example fix
# before
for wf_id in all_ids:
service.delete(wf_id)
# after
for wf_id in all_ids:
if service.get(wf_id).workflow.meta.category is not WorkflowCategory.Default:
service.delete(wf_id) Defensive patterns
Strategy: validation
Validate before calling
record = service.get(workflow_id)
if record.workflow.meta.category is WorkflowCategory.Default:
raise SkipDelete(f"{workflow_id} is a default workflow") Type guard
def deletable(record: WorkflowRecordDTO) -> bool:
return record.workflow.meta.category is not WorkflowCategory.Default Try / catch
try:
service.delete(workflow_id)
except ValueError as e:
if "Default workflows cannot be deleted" in str(e):
logger.info("skipped default workflow %s", workflow_id)
else:
raise Prevention
- Check category via get() before batch deletes
- Exclude default workflow ids (queryable by category) from cleanup jobs
- Never assume every id in the library is user-deletable
When it happens
Trigger: Calling delete(workflow_id) on a workflow whose stored record has meta.category == WorkflowCategory.Default; batch-deletion scripts sweeping all ids.
Common situations: 'Delete all' UI actions or cleanup scripts; DB cleanup jobs not filtering category; attempts to remove a default workflow that appears duplicated in the library.
Related errors
- Default workflows cannot be created via this method
- Default workflows cannot be updated
- A saved workflow must be selected before executing call_save
- The selected saved workflow '${self.workflow_id}' could not
- Workflow return key must not be empty.
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/6a46d96b6bd92a56.
Report an issue: GitHub.