{"record":{"id":"07725bdc30fd250f","repo":"conductor-oss/conductor","slug":"workflow-s-is-not-in-terminal-state-unable-to-r","errorCode":null,"errorMessage":"Workflow: %s is not in terminal state, unable to restart.","messagePattern":"Workflow: (.+?) is not in terminal state, unable to restart\\.","errorType":"exception","errorClass":"ConflictException","httpStatus":409,"severity":"error","filePath":"core/src/main/java/com/netflix/conductor/core/execution/WorkflowExecutorOps.java","lineNumber":199,"sourceCode":"\n    /**\n     * @param workflowId the id of the workflow to be restarted\n     * @param useLatestDefinitions if true, use the latest workflow and task definitions upon\n     *     restart\n     * @throws ConflictException Workflow is not in a terminal state.\n     * @throws NotFoundException Workflow definition is not found or Workflow is deemed\n     *     non-restartable as per workflow definition.\n     */\n    @Override\n    public void restart(String workflowId, boolean useLatestDefinitions) {\n        final WorkflowModel workflow = executionDAOFacade.getWorkflowModel(workflowId, true);\n\n        if (!workflow.getStatus().isTerminal()) {\n            String errorMsg =\n                    String.format(\n                            \"Workflow: %s is not in terminal state, unable to restart.\", workflow);\n            LOGGER.error(errorMsg);\n            throw new ConflictException(errorMsg);\n        }\n\n        WorkflowDef workflowDef;\n        if (useLatestDefinitions) {\n            workflowDef =\n                    metadataDAO\n                            .getLatestWorkflowDef(workflow.getWorkflowName())\n                            .orElseThrow(\n                                    () ->\n                                            new NotFoundException(\n                                                    \"Unable to find latest definition for %s\",\n                                                    workflowId));\n            workflow.setWorkflowDefinition(workflowDef);\n            workflowDef = metadataMapperService.populateTaskDefinitions(workflowDef);\n        } else {\n            workflowDef =\n                    Optional.ofNullable(workflow.getWorkflowDefinition())\n                            .orElseGet(","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/conductor-oss/conductor/blob/cf7c3e4a8adfb158be778ab1ec525323c363cd3a/core/src/main/java/com/netflix/conductor/core/execution/WorkflowExecutorOps.java#L181-L217","documentation":"restart requires the workflow to already be in a terminal state; if it is still running (RUNNING, PAUSED, etc.) the engine throws a ConflictException. Restart resets and re-creates the workflow, which is only safe on a finished workflow.","triggerScenarios":"Calling WorkflowExecutor.restart on a workflow whose status is not terminal (e.g. RUNNING, PAUSED).","commonSituations":"Automation that restarts on failure without checking status; race where the workflow is still draining; UI allowing restart on a paused workflow.","solutions":["Wait for the workflow to reach a terminal status (or terminate it) before calling restart.","Check workflow.getStatus().isTerminal() and surface a clear message if not.","Use pause + terminate if you need to force a running workflow into a restartable state."],"exampleFix":"// before\nworkflowExecutor.restart(workflowId, false);\n\n// after\nWorkflowModel wf = executionDAOFacade.getWorkflowModel(workflowId, true);\nif (wf.getStatus().isTerminal()) {\n    workflowExecutor.restart(workflowId, false);\n} else {\n    // terminate first, or wait\n}","handlingStrategy":"validation","validationCode":"WorkflowModel wf = executionDAOFacade.getWorkflowModel(workflowId, true);\nif (!wf.getStatus().isTerminal()) {\n    // wait, or terminate first\n    throw new IllegalStateException(\"workflow not terminal: \" + wf.getStatus());\n}\nworkflowExecutor.restart(workflowId, useLatestDefinitions);","typeGuard":null,"tryCatchPattern":"try {\n    workflowExecutor.restart(workflowId, useLatestDefinitions);\n} catch (ConflictException e) {\n    // workflow still running; wait or terminate first\n}","preventionTips":["Ensure the workflow is terminal before calling restart.","Terminate or wait for completion if it is still running.","Guard restart automation with an isTerminal() check."],"tags":["conductor","workflow","lifecycle","restart","conflict","terminal-state"],"backgroundTag":null,"analyzedSha":"cf7c3e4a8adfb158be778ab1ec525323c363cd3a","analyzedAt":"2026-08-14T03:33:19.897Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}