{"record":{"id":"086bb531cffdaad5","repo":"flowable/flowable-engine","slug":"variablename-is-null-086bb5","errorCode":null,"errorMessage":"variableName is null","messagePattern":"variableName 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":47,"sourceCode":"\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        }\n\n        return hasVariable;\n    }","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/HasExecutionVariableCmd.java#L29-L65","documentation":"HasExecutionVariableCmd.execute() throws FlowableIllegalArgumentException(\"variableName is null\") when the variable name argument is null. Even with a valid execution, the engine cannot test existence of an unnamed variable, so the argument is rejected up front.","triggerScenarios":"runtimeService.hasVariable(executionId, null) or hasVariableLocal(executionId, null), typically when the variable name comes from configuration or a dynamic map key that is missing.","commonSituations":"Variable names read from a properties/YAML config where the key was renamed or omitted; iterating a map with null keys; refactors renaming a constant but not all usages.","solutions":["Pass a non-null, correct variable name string to hasVariable/hasVariableLocal.","Centralize variable names as constants and validate config files for missing name entries.","Guard call sites that derive the name dynamically: skip or fail fast when the derived name is null.","Catch FlowableIllegalArgumentException and report which variable name was missing."],"exampleFix":"// before\nboolean has = runtimeService.hasVariable(executionId, config.getVarName()); // may be null\n// after\nif (config.getVarName() == null) {\n    throw new IllegalStateException(\"Variable name not configured\");\n}\nboolean has = runtimeService.hasVariable(executionId, config.getVarName());","handlingStrategy":"validation","validationCode":"if (variableName == null || variableName.isEmpty()) {\n    throw new IllegalArgumentException(\"variableName must be provided\");\n}","typeGuard":"boolean hasVariableName(String name) { return name != null && !name.isEmpty(); }","tryCatchPattern":"try {\n    return runtimeService.hasVariable(executionId, variableName);\n} catch (FlowableIllegalArgumentException e) {\n    throw new BadRequestException(\"variableName is required\", e);\n}","preventionTips":["Define variable names as constants in one place","Validate configuration files supplying variable names at startup","Reject null keys when iterating dynamic variable-name maps"],"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-18T16:30:33.424Z"}