{"record":{"id":"94cfae4ac5f94fa9","repo":"flowable/flowable-engine","slug":"no-execution-found-for-id","errorCode":null,"errorMessage":"No execution found for id ''","messagePattern":"No execution found for id ''","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/CompleteAdhocSubProcessCmd.java","lineNumber":46,"sourceCode":"/**\n * @author Tijs Rademakers\n */\npublic class CompleteAdhocSubProcessCmd implements Command<Void>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n\n    protected String executionId;\n\n    public CompleteAdhocSubProcessCmd(String executionId) {\n        this.executionId = executionId;\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(commandContext);\n        ExecutionEntity execution = executionEntityManager.findById(executionId);\n        if (execution == null) {\n            throw new FlowableObjectNotFoundException(\"No execution found for id '\" + executionId + \"'\", ExecutionEntity.class);\n        }\n\n        if (!(execution.getCurrentFlowElement() instanceof AdhocSubProcess)) {\n            throw new FlowableException(\"The current flow element of the requested \" + execution + \" is not an ad-hoc sub process\");\n        }\n\n        List<? extends ExecutionEntity> childExecutions = execution.getExecutions();\n        if (childExecutions.size() > 0) {\n            throw new FlowableException(\"Ad-hoc sub process has running child executions that need to be completed first. \" + execution);\n        }\n\n        ExecutionEntity outgoingFlowExecution = executionEntityManager.createChildExecution(execution.getParent());\n        outgoingFlowExecution.setCurrentFlowElement(execution.getCurrentFlowElement());\n\n        executionEntityManager.deleteExecutionAndRelatedData(execution, null, false);\n\n        CommandContextUtil.getAgenda().planTakeOutgoingSequenceFlowsOperation(outgoingFlowExecution, true);\n","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/CompleteAdhocSubProcessCmd.java#L28-L64","documentation":"CompleteAdhocSubProcessCmd completes an ad-hoc sub-process execution. If no execution exists for the given executionId, Flowable throws FlowableObjectNotFoundException with ExecutionEntity as the missing type.","triggerScenarios":"runtimeService.completeAdhocSubProcess(executionId, ...) with an execution id that was deleted, already completed, or never existed.","commonSituations":"Stale execution ids held after the process instance ended; typo'd or cross-instance ids; async completion racing deletion of the execution.","solutions":["Verify the execution exists via runtimeService.createExecutionQuery().executionId(id).singleResult().","Refresh the executionId from a fresh process instance lookup instead of caching it.","Ensure the process instance has not already completed/terminated before calling the API."],"exampleFix":"// before\nruntimeService.completeAdhocSubProcess(executionId, outcome);\n// after\nExecutionEntity e = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(executionId).singleResult();\nif (e != null) {\n    runtimeService.completeAdhocSubProcess(executionId, outcome);\n}","handlingStrategy":"validation","validationCode":"Execution e = runtimeService.createExecutionQuery().executionId(executionId).singleResult();\nif (e == null) {\n    throw new IllegalArgumentException(\"Execution not found: \" + executionId);\n}","typeGuard":null,"tryCatchPattern":"try {\n    runtimeService.completeAdhocSubProcess(executionId, outcome);\n} catch (FlowableObjectNotFoundException e) {\n    // execution gone; refresh process state\n}","preventionTips":["Do not cache execution ids across process lifecycle events.","Confirm the process instance is still running before completing."],"tags":["flowable","execution","not-found","ad-hoc-subprocess"],"backgroundTag":"resource-not-found","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"}