{"record":{"id":"4220c15c1b70560e","repo":"invoke-ai/InvokeAI","slug":"default-workflows-cannot-be-created-via-this-metho","errorCode":null,"errorMessage":"Default workflows cannot be created via this method","messagePattern":"Default workflows cannot be created via this method","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"invokeai/app/services/workflow_records/workflow_records_sqlite.py","lineNumber":58,"sourceCode":"                SELECT workflow_id, workflow, name, created_at, updated_at, opened_at, user_id, is_public\n                FROM workflow_library\n                WHERE workflow_id = ?;\n                \"\"\",\n                (workflow_id,),\n            )\n            row = cursor.fetchone()\n        if row is None:\n            raise WorkflowNotFoundError(f\"Workflow with id {workflow_id} not found\")\n        return WorkflowRecordDTO.from_dict(dict(row))\n\n    def create(\n        self,\n        workflow: WorkflowWithoutID,\n        user_id: str = WORKFLOW_LIBRARY_DEFAULT_USER_ID,\n        is_public: bool = False,\n    ) -> WorkflowRecordDTO:\n        if workflow.meta.category is WorkflowCategory.Default:\n            raise ValueError(\"Default workflows cannot be created via this method\")\n\n        with self._db.transaction() as cursor:\n            workflow_with_id = Workflow(**workflow.model_dump(), id=uuid_string())\n            cursor.execute(\n                \"\"\"--sql\n                INSERT OR IGNORE INTO workflow_library (\n                    workflow_id,\n                    workflow,\n                    user_id,\n                    is_public\n                )\n                VALUES (?, ?, ?, ?);\n                \"\"\",\n                (workflow_with_id.id, workflow_with_id.model_dump_json(), user_id, is_public),\n            )\n        return self.get(workflow_with_id.id)\n\n    def update(self, workflow: Workflow, user_id: Optional[str] = None) -> WorkflowRecordDTO:","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/workflow_records/workflow_records_sqlite.py#L40-L76","documentation":"create() refuses to insert workflows whose meta.category is WorkflowCategory.Default. Default workflows are managed exclusively by _sync_default_workflows (shipped with the app), so the public create path rejects them to avoid duplicate or user-modified default records.","triggerScenarios":"Calling create(workflow) where workflow.meta.category == WorkflowCategory.Default, e.g. round-tripping a default workflow's JSON back into create.","commonSituations":"Re-importing an exported default workflow; copying a built-in workflow as a template without changing its category; scripts that clone workflows wholesale.","solutions":["Change meta.category to WorkflowCategory.Custom before calling create","Or use the app's built-in default workflows directly instead of re-creating them","Clone-with-category helper: dump the model, set category='custom', then create"],"exampleFix":"// before\nservice.create(default_workflow)  # category: Default\n// after\ndata = default_workflow.model_dump()\ndata[\"meta\"][\"category\"] = \"custom\"\nservice.create(WorkflowWithoutID(**data))","handlingStrategy":"validation","validationCode":"from invokeai.app.services.workflow_records.workflow_records_common import WorkflowCategory\nassert workflow.meta.category is not WorkflowCategory.Default, \"clone with Custom category before create\"","typeGuard":null,"tryCatchPattern":"try:\n    record = service.create(workflow)\nexcept ValueError as e:\n    if \"Default workflows cannot be created\" in str(e):\n        data = workflow.model_dump(); data[\"meta\"][\"category\"] = \"custom\"\n        record = service.create(WorkflowWithoutID(**data))\n    else:\n        raise","preventionTips":["Always set category to Custom for user-created/imported workflows","Never round-trip default workflow JSON back through create()","Write a clone helper that strips Default markers"],"tags":["workflow","validation","business-rule"],"backgroundTag":"forbidden-operation","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}