{"record":{"id":"b26d7a44d5888932","repo":"flowable/flowable-engine","slug":"executionid-is-null-b26d7a","errorCode":null,"errorMessage":"executionId is null","messagePattern":"executionId is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/HasExecutionVariableCmd.java","lineNumber":44,"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 FlowableIllegalArgumentException(\"executionId is null\");\n        }\n        if (variableName == null) {\n            throw new FlowableIllegalArgumentException(\"variableName is null\");\n        }\n\n        ExecutionEntity execution = CommandContextUtil.getExecutionEntityManager(commandContext).findById(executionId);\n\n        if (execution == null) {\n            throw new FlowableObjectNotFoundException(\"execution \" + executionId + \" doesn't exist\", Execution.class);\n        }\n\n        boolean hasVariable = false;\n\n        if (isLocal) {\n            hasVariable = execution.hasVariableLocal(variableName);\n        } else {\n            hasVariable = execution.hasVariable(variableName);\n        }","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/HasExecutionVariableCmd.java#L26-L62","documentation":"HasExecutionVariableCmd.execute() throws FlowableIllegalArgumentException(\"executionId is null\") when the execution id argument is null. The command checks whether a variable exists on an execution, which requires a valid execution reference.","triggerScenarios":"Calling runtimeService.hasVariable(null, variableName) / hasVariableLocal(null, name) — the runtime service builds HasExecutionVariableCmd with a null executionId.","commonSituations":"executionId taken from a process instance lookup that returned null; REST handler with a missing path parameter mapped to null; code path where the execution was conditionally resolved but the variable check ran unconditionally.","solutions":["Pass a non-null executionId to runtimeService.hasVariable/hasVariableLocal.","Resolve the executionId from a verified ExecutionEntity/ProcessInstance before checking variables.","Fix the upstream lookup that yielded null (e.g. processInstanceId -> execution resolution).","Catch FlowableIllegalArgumentException and return a 400-style validation error."],"exampleFix":"// before\nboolean has = runtimeService.hasVariable(ctx.getExecutionId(), \"approved\");\n// after\nif (ctx.getExecutionId() != null) {\n    boolean has = runtimeService.hasVariable(ctx.getExecutionId(), \"approved\");\n}","handlingStrategy":"validation","validationCode":"if (executionId == null || executionId.isEmpty()) {\n    throw new IllegalArgumentException(\"executionId must be provided\");\n}","typeGuard":"boolean hasExecutionId(String id) { return id != null && !id.isEmpty(); }","tryCatchPattern":"try {\n    return runtimeService.hasVariable(executionId, variableName);\n} catch (FlowableIllegalArgumentException e) {\n    throw new BadRequestException(\"Invalid hasVariable arguments: \" + e.getMessage(), e);\n}","preventionTips":["Resolve executionId from a live ExecutionEntity before variable checks","Never let REST path parameters bind to null silently — validate them","Guard conditional lookups so dependent calls run only when the id exists"],"tags":["flowable","null-argument","variables","validation"],"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"}