{"record":{"id":"5026278ec49b3d7e","repo":"flowable/flowable-engine","slug":"variablename-is-null-502627","errorCode":null,"errorMessage":"variableName is null","messagePattern":"variableName is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/HasTaskVariableCmd.java","lineNumber":50,"sourceCode":"    private static final long serialVersionUID = 1L;\n    \n    protected String taskId;\n    protected String variableName;\n    protected boolean isLocal;\n\n    public HasTaskVariableCmd(String taskId, String variableName, boolean isLocal) {\n        this.taskId = taskId;\n        this.variableName = variableName;\n        this.isLocal = isLocal;\n    }\n\n    @Override\n    public Boolean execute(CommandContext commandContext) {\n        if (taskId == null) {\n            throw new FlowableIllegalArgumentException(\"taskId is null\");\n        }\n        if (variableName == null) {\n            throw new FlowableIllegalArgumentException(\"variableName is null\");\n        }\n\n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        TaskEntity task = cmmnEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId);\n\n        if (task == null) {\n            throw new FlowableObjectNotFoundException(\"task \" + taskId + \" doesn't exist\", Task.class);\n        }\n        boolean hasVariable = false;\n\n        if (isLocal) {\n            hasVariable = task.hasVariableLocal(variableName);\n        } else {\n            hasVariable = task.hasVariable(variableName);\n        }\n\n        return hasVariable;\n    }","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/HasTaskVariableCmd.java#L32-L68","documentation":"HasTaskVariableCmd.execute throws FlowableIllegalArgumentException when variableName is null. The task id passed validation, but a null variable name cannot be tested against the task's variables, so the command rejects it before fetching the task.","triggerScenarios":"Calling hasVariable(taskId, null) or hasVariableLocal(taskId, null), usually because the name came from missing config, a null map key, or an unset field.","commonSituations":"Variable names externalized to configuration that is missing, dynamic names built from user input that is absent, refactoring removing a constant value.","solutions":["Validate the variable name before the call","Fix the configuration/source producing the null name","Use constants/enums for variable names"],"exampleFix":"// before\nboolean has = taskService.hasVariable(taskId, name);\n// after\nObjects.requireNonNull(name, \"variableName required\");\nboolean has = taskService.hasVariable(taskId, name);","handlingStrategy":"validation","validationCode":"if (variableName == null || variableName.isEmpty()) {\n    throw new IllegalArgumentException(\"variableName is required\");\n}","typeGuard":"boolean validVariableName(String name) {\n    return name != null && !name.trim().isEmpty();\n}","tryCatchPattern":"try {\n    return taskService.hasVariable(taskId, variableName);\n} catch (FlowableIllegalArgumentException e) {\n    log.error(\"Missing variableName: {}\", e.getMessage());\n    return false;\n}","preventionTips":["Use constants for task variable names","Validate config-driven variable names at startup","Reject null names at API boundaries in your own service layer"],"tags":["flowable","cmmn","null-argument","task"],"backgroundTag":"null-argument","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"}