{"record":{"id":"6274f318b06c1346","repo":"flowable/flowable-engine","slug":"executionid-is-null-6274f3","errorCode":null,"errorMessage":"executionId is null","messagePattern":"executionId is null","errorType":"exception","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/HasExecutionVariableCmd.java","lineNumber":43,"sourceCode":" * @author Frederik Heremans\n */\npublic class HasExecutionVariableCmd implements Command<Boolean>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    protected String executionId;\n    protected String variableName;\n    protected boolean isLocal;\n\n    public HasExecutionVariableCmd(String executionId, String variableName, boolean isLocal) {\n        this.executionId = executionId;\n        this.variableName = variableName;\n        this.isLocal = isLocal;\n    }\n\n    @Override\n    public Boolean execute(CommandContext commandContext) {\n        if (executionId == null) {\n            throw new ActivitiIllegalArgumentException(\"executionId is null\");\n        }\n        if (variableName == null) {\n            throw new ActivitiIllegalArgumentException(\"variableName is null\");\n        }\n\n        ExecutionEntity execution = commandContext\n                .getExecutionEntityManager()\n                .findExecutionById(executionId);\n\n        if (execution == null) {\n            throw new ActivitiObjectNotFoundException(\"execution \" + executionId + \" doesn't exist\", Execution.class);\n        }\n\n        boolean hasVariable = false;\n\n        if (isLocal) {\n            hasVariable = execution.hasVariableLocal(variableName);\n        } else {","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/HasExecutionVariableCmd.java#L25-L61","documentation":"HasExecutionVariableCmd.execute validates inputs and throws ActivitiIllegalArgumentException(\"executionId is null\") when the executionId parameter is null. The command checks whether an execution has a variable, and requires both a non-null execution id and variable name. The RAISED-IN trace shows it fires during activity behavior execution, i.e. inside the process itself.","triggerScenarios":"Calling taskService.hasVariable(executionId, variableName) with null executionId, or a delegate/behavior invoking hasVariable during executionActivityBehavior with an execution that was not properly wired (null id).","commonSituations":"Custom JavaDelegates or ExecutionListeners calling hasVariable before the execution entity was persisted; Spring beans holding a stale/blank executionId field; tests invoking the command directly without an execution.","solutions":["Null-check executionId before calling hasVariable/hasVariableLocal.","In delegates, use DelegateExecution.getVariable/hasVariable directly instead of round-tripping through the service with an id.","Verify the execution is persisted (execution.getId() != null) before service-based checks.","Fix bean wiring so the executionId is populated from the delegate context, not a stale field."],"exampleFix":"// before\nboolean has = taskService.hasVariable(executionId, \"approved\");\n// after\nif (executionId == null) {\n    throw new IllegalArgumentException(\"executionId is required\");\n}\nboolean has = taskService.hasVariable(executionId, \"approved\");","handlingStrategy":"validation","validationCode":"if (executionId == null) throw new IllegalArgumentException(\"executionId must not be null\");","typeGuard":null,"tryCatchPattern":"try {\n    return taskService.hasVariable(executionId, variableName);\n} catch (ActivitiIllegalArgumentException e) {\n    return false;\n}","preventionTips":["Inside delegates/listeners use DelegateExecution.hasVariable instead of service-by-id calls.","Ensure the execution is persisted before id-based checks.","Do not cache executionId in beans across invocations."],"tags":["null","execution","variable"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}