{"record":{"id":"443f9ef8127f0166","repo":"invoke-ai/InvokeAI","slug":"workflow-with-id-workflow-id-not-found","errorCode":null,"errorMessage":"Workflow with id {workflow_id} not found","messagePattern":"Workflow with id (.+?) not found","errorType":"exception","errorClass":"WorkflowNotFoundError","httpStatus":404,"severity":"error","filePath":"invokeai/app/services/workflow_records/workflow_records_sqlite.py","lineNumber":48,"sourceCode":"\n    def start(self, invoker: Invoker) -> None:\n        self._invoker = invoker\n        self._sync_default_workflows()\n\n    def get(self, workflow_id: str) -> WorkflowRecordDTO:\n        \"\"\"Gets a workflow by ID. Updates the opened_at column.\"\"\"\n        with self._db.transaction() as cursor:\n            cursor.execute(\n                \"\"\"--sql\n                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,","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/workflow_records/workflow_records_sqlite.py#L30-L66","documentation":"WorkflowRecordsSQLite.get raises WorkflowNotFoundError when no row with the given workflow_id exists in the workflow_library table. Many public methods (create, update, delete, update_is_public, _sync_default_workflows) call get internally, so this error surfaces from those too when operating on a nonexistent or already-deleted workflow.","triggerScenarios":"get(id) with a stale/typo'd UUID; update/delete/update_is_public on a workflow deleted in another session; calling create with an id collision path that then re-gets a purged row.","commonSituations":"Client caches holding workflow ids after a DB reset or migration; shared databases where another user deleted the workflow; restoring old workflow JSON with ids from a wiped database.","solutions":["Verify the workflow_id exists (query the workflow library UI or SELECT from workflow_library) before mutating","Catch WorkflowNotFoundError and refresh the client's workflow list","If DB was reset, re-import the workflow instead of referencing the old id"],"exampleFix":"# before\nrecord = service.update(Workflow(id=\"abc-123\", ...))\n# after\ntry:\n    record = service.update(Workflow(id=\"abc-123\", ...))\nexcept WorkflowNotFoundError:\n    record = service.create(WorkflowWithoutID(**workflow.model_dump(exclude={\"id\"})))","handlingStrategy":"try-catch","validationCode":"def workflow_exists(service, workflow_id: str) -> bool:\n    try:\n        service.get(workflow_id)\n        return True\n    except WorkflowNotFoundError:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    record = service.update(workflow)\nexcept WorkflowNotFoundError:\n    logger.info(\"workflow %s missing, recreating\", workflow.id)\n    record = service.create(WorkflowWithoutID(**workflow.model_dump(exclude={\"id\"})))","preventionTips":["Refresh cached workflow ids after DB resets or migrations","Use service.list_all() to confirm ids before bulk operations","Handle deletion in other sessions gracefully instead of assuming records persist"],"tags":["database","sqlite","not-found"],"backgroundTag":"record-not-found","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}