{"record":{"id":"5565db8986547085","repo":"flowable/flowable-engine","slug":"variablename-is-null-5565db","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/GetTaskVariableInstanceCmd.java","lineNumber":48,"sourceCode":"    private static final long serialVersionUID = 1L;\n    \n    protected String taskId;\n    protected String variableName;\n    protected boolean isLocal;\n\n    public GetTaskVariableInstanceCmd(String taskId, String variableName, boolean isLocal) {\n        this.taskId = taskId;\n        this.variableName = variableName;\n        this.isLocal = isLocal;\n    }\n\n    @Override\n    public VariableInstance 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\n        VariableInstance variableEntity;\n\n        if (isLocal) {\n            variableEntity = task.getVariableInstanceLocal(variableName, false);\n        } else {\n            variableEntity = task.getVariableInstance(variableName, false);\n        }\n\n        return variableEntity;","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetTaskVariableInstanceCmd.java#L30-L66","documentation":"GetTaskVariableInstanceCmd.execute() requires a variable name after validating taskId. If variableName is null it throws FlowableIllegalArgumentException('variableName is null'), since fetching a single variable instance is meaningless without knowing which variable to look up.","triggerScenarios":"Calling cmmnTaskService.getVariableInstance(taskId, null) or getVariableInstanceLocal(taskId, null); a variable name sourced from config/UI that was never set.","commonSituations":"Variable name read from a properties file or request body with a missing key; typo where the name constant is null by initialization order; generic wrapper code that forwards a nullable name parameter.","solutions":["Pass a non-empty variableName string to getVariableInstance/getVariableInstanceLocal.","Validate/trim the variable name parameter before invoking the task service.","If iterating variables dynamically, use getVariableInstances(taskId) instead of per-name lookup."],"exampleFix":"// before\nVariableInstance vi = cmmnTaskService.getVariableInstance(taskId, config.get(\"varName\"));\n// after\nString varName = config.get(\"varName\");\nif (varName == null || varName.isEmpty()) {\n    throw new IllegalArgumentException(\"varName must be configured\");\n}\nVariableInstance vi = cmmnTaskService.getVariableInstance(taskId, varName);","handlingStrategy":"validation","validationCode":"if (variableName == null || variableName.trim().isEmpty()) { throw new IllegalArgumentException(\"variableName is required\"); }","typeGuard":"boolean hasVariableName(String name) { return name != null && !name.trim().isEmpty(); }","tryCatchPattern":"try { return taskService.getVariableInstance(taskId, variableName); } catch (FlowableIllegalArgumentException e) { log.warn(\"Invalid variable lookup: {}\", e.getMessage()); return null; }","preventionTips":["Define variable names as constants rather than literals/config lookups","Validate external input (forms, requests) for required variable names","Prefer getVariableInstances when names are dynamic"],"tags":["flowable","cmmn","null-argument","task-variables"],"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"}