{"record":{"id":"58ce38a3916eeae7","repo":"flowable/flowable-engine","slug":"cannot-set-suspension-state-for-execution-execut","errorCode":null,"errorMessage":"Cannot set suspension state for execution '{executionEntity}': not a process instance.","messagePattern":"Cannot set suspension state for execution '(.+?)': not a process instance\\.","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/AbstractSetProcessInstanceStateCmd.java","lineNumber":67,"sourceCode":"        this.processInstanceId = processInstanceId;\r\n    }\r\n\r\n    @Override\r\n    public Void execute(CommandContext commandContext) {\r\n\r\n        if (processInstanceId == null) {\r\n            throw new FlowableIllegalArgumentException(\"ProcessInstanceId cannot be null.\");\r\n        }\r\n\r\n        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\r\n        ExecutionEntityManager executionEntityManager = processEngineConfiguration.getExecutionEntityManager();\r\n        ExecutionEntity executionEntity = executionEntityManager.findById(processInstanceId);\r\n\r\n        if (executionEntity == null) {\r\n            throw new FlowableObjectNotFoundException(\"Cannot find processInstance for id '\" + processInstanceId + \"'.\", Execution.class);\r\n        }\r\n        if (!executionEntity.isProcessInstanceType()) {\r\n            throw new FlowableException(\"Cannot set suspension state for execution '\" + executionEntity + \"': not a process instance.\");\r\n        }\r\n\r\n        if (Flowable5Util.isFlowable5ProcessDefinitionId(commandContext, executionEntity.getProcessDefinitionId())) {\r\n            if (getNewState() == SuspensionState.ACTIVE) {\r\n                processEngineConfiguration.getFlowable5CompatibilityHandler().activateProcessInstance(processInstanceId);\r\n            } else {\r\n                processEngineConfiguration.getFlowable5CompatibilityHandler().suspendProcessInstance(processInstanceId);\r\n            }\r\n            return null;\r\n        }\r\n\r\n        SuspensionStateUtil.setSuspensionState(executionEntity, getNewState());\r\n        executionEntityManager.update(executionEntity, false);\r\n\r\n        // All child executions are suspended\r\n        Collection<ExecutionEntity> childExecutions = executionEntityManager.findChildExecutionsByProcessInstanceId(processInstanceId);\r\n        for (ExecutionEntity childExecution : childExecutions) {\r\n            if (!childExecution.getId().equals(processInstanceId)) {\r","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/AbstractSetProcessInstanceStateCmd.java#L49-L85","documentation":"FlowableException thrown by AbstractSetProcessInstanceStateCmd.execute when the id supplied to activate/suspend resolves to an execution that exists but is not of type process instance (e.g. a child/concurrent execution or a task execution). Only the root execution representing the whole process instance may have its suspension state changed this way.","triggerScenarios":"Calling runtimeService.activateProcessInstanceById(id)/suspendProcessInstanceById(id) with an executionId (from a sub-execution or concurrent branch) instead of the processInstance's own id.","commonSituations":"Copying an executionId from an ExecutionQuery result of a nested scope; ids taken from activity-level listeners; mixing execution and process-instance APIs.","solutions":["Query the process instance id instead: runtimeService.createProcessInstanceQuery().processInstanceId(execution.getProcessInstanceId()).","From an Execution object, use getProcessInstanceId() (or getRootProcessInstanceId()) rather than getId().","Validate execution.isProcessInstanceType() (via a query on ExecutionQuery.processInstanceId) before calling the suspend/activate API.","Use runtimeService.createExecutionQuery().executionId(id).singleResult() to inspect the type of the id you hold."],"exampleFix":"// before\nExecution e = executions.get(0); // child execution\nruntimeService.suspendProcessInstanceById(e.getId());\n// after\nruntimeService.suspendProcessInstanceById(e.getProcessInstanceId());","handlingStrategy":"validation","validationCode":"Execution e = runtimeService.createExecutionQuery().executionId(id).singleResult();\nif (e == null || !e.getId().equals(e.getProcessInstanceId())) {\n    throw new IllegalArgumentException(\"Not a process instance id: \" + id);\n}","typeGuard":null,"tryCatchPattern":"try {\n    runtimeService.activateProcessInstanceById(id);\n} catch (FlowableException e) {\n    if (e.getMessage().contains(\"not a process instance\")) {\n        runtimeService.activateProcessInstanceById(\n            runtimeService.createExecutionQuery().executionId(id).singleResult().getProcessInstanceId());\n    }\n}","preventionTips":["Use getProcessInstanceId(), never getId(), on Execution objects.","Prefer query-by-processInstanceId APIs over execution-level APIs.","Never persist raw execution ids as process instance references."],"tags":["flowable","process-instance","wrong-id","suspension"],"backgroundTag":"invalid-identifier","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}