{"record":{"id":"1b7f0bcc62d3a1b1","repo":"flowable/flowable-engine","slug":"null-execution-passed","errorCode":null,"errorMessage":"Null execution passed","messagePattern":"Null execution passed","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/delegate/DelegateHelper.java","lineNumber":70,"sourceCode":"    /**\n     * To be used in an {@link ActivityBehavior} or {@link JavaDelegate}: leaves the current activity via one specific sequenceflow.\n     */\n    public static void leaveDelegate(DelegateExecution delegateExecution, String sequenceFlowId) {\n        String processDefinitionId = delegateExecution.getProcessDefinitionId();\n        org.flowable.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinitionId);\n        FlowElement flowElement = process.getFlowElement(sequenceFlowId);\n        if (flowElement instanceof SequenceFlow) {\n            delegateExecution.setCurrentFlowElement(flowElement);\n            CommandContextUtil.getAgenda().planTakeOutgoingSequenceFlowsOperation((ExecutionEntity) delegateExecution, false);\n        } else {\n            throw new FlowableException(sequenceFlowId + \" does not match a sequence flow for \" + delegateExecution);\n        }\n    }\n\n    /**\n     * Returns the {@link BpmnModel} matching the process definition bpmn model for the process definition of the passed {@link DelegateExecution}.\n     */\n    public static BpmnModel getBpmnModel(DelegateExecution execution) {\n        if (execution == null) {\n            throw new FlowableException(\"Null execution passed\");\n        }\n        return ProcessDefinitionUtil.getBpmnModel(execution.getProcessDefinitionId());\n    }\n\n    /**\n     * Returns the current {@link FlowElement} where the {@link DelegateExecution} is currently at.\n     */\n    public static FlowElement getFlowElement(DelegateExecution execution) {\n        BpmnModel bpmnModel = getBpmnModel(execution);\n        FlowElement flowElement = bpmnModel.getFlowElement(execution.getCurrentActivityId());\n        if (flowElement == null) {\n            throw new FlowableException(\"Could not find a FlowElement for activityId \" + execution.getCurrentActivityId() + \" in \" + execution);\n        }\n        return flowElement;\n    }\n","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/delegate/DelegateHelper.java#L52-L88","documentation":"DelegateHelper.getBpmnModel(DelegateExecution) requires a non-null execution because it derives the BPMN model from execution.getProcessDefinitionId(). A null argument is rejected immediately with 'Null execution passed'.","triggerScenarios":"Passing null to DelegateHelper.getBpmnModel(...) — e.g. a listener framework that supplies no execution, or a helper method whose execution argument wasn't initialized before the call.","commonSituations":"Custom delegate/listener code paths that construct DelegateExecution lazily; calling static helper methods in unit tests without a real execution; refactoring that dropped the execution parameter wiring.","solutions":["Ensure the DelegateExecution passed in is the one provided by the engine to your JavaDelegate/Listener","Guard with a null check and provide a meaningful error or fallback before calling the helper","In tests, mock DelegateExecution including a valid processDefinitionId"],"exampleFix":"// before\nBpmnModel model = DelegateHelper.getBpmnModel(null);\n\n// after\nif (execution == null) {\n    throw new IllegalStateException(\"execution required to resolve bpmn model\");\n}\nBpmnModel model = DelegateHelper.getBpmnModel(execution);","handlingStrategy":"type-guard","validationCode":"Objects.requireNonNull(execution, \"DelegateExecution must not be null before calling DelegateHelper\");","typeGuard":"boolean hasBpmnModelContext(DelegateExecution e) {\n    return e != null && e.getProcessDefinitionId() != null;\n}","tryCatchPattern":"try {\n    BpmnModel m = DelegateHelper.getBpmnModel(execution);\n} catch (FlowableException e) {\n    if (\"Null execution passed\".equals(e.getMessage())) {\n        // supply the engine-provided execution\n    } else throw e;\n}","preventionTips":["Never call DelegateHelper statically outside a delegate/listener scope with a hand-made execution","In unit tests, mock DelegateExecution with a real processDefinitionId before invoking helpers"],"tags":["flowable","delegate","null-check","bpmn"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}