{"record":{"id":"a85484e298d22b79","repo":"flowable/flowable-engine","slug":"variablename-is-null","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/CmmnTaskServiceImpl.java","lineNumber":332,"sourceCode":"    @Override\n    public <T> T getVariableLocal(String taskId, String variableName, Class<T> variableClass) {\n        return variableClass.cast(getVariableLocal(taskId, variableName));\n    }\n\n    @Override\n    public List<VariableInstance> getVariableInstancesLocalByTaskIds(Set<String> taskIds) {\n        return commandExecutor.execute(new GetTasksLocalVariablesCmd(taskIds));\n    }\n\n    @Override\n    public boolean hasVariableLocal(String taskId, String variableName) {\n        return commandExecutor.execute(new HasTaskVariableCmd(taskId, variableName, true));\n    }\n\n    @Override\n    public void setVariable(String taskId, String variableName, Object value) {\n        if (variableName == null) {\n            throw new FlowableIllegalArgumentException(\"variableName is null\");\n        }\n        Map<String, Object> variables = new HashMap<>();\n        variables.put(variableName, value);\n        commandExecutor.execute(new SetTaskVariablesCmd(taskId, variables, false));\n    }\n\n    @Override\n    public void setVariableLocal(String taskId, String variableName, Object value) {\n        if (variableName == null) {\n            throw new FlowableIllegalArgumentException(\"variableName is null\");\n        }\n        Map<String, Object> variables = new HashMap<>();\n        variables.put(variableName, value);\n        commandExecutor.execute(new SetTaskVariablesCmd(taskId, variables, true));\n    }\n\n    @Override\n    public void setVariables(String taskId, Map<String, ? extends Object> variables) {","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/CmmnTaskServiceImpl.java#L314-L350","documentation":"Argument validation in CmmnTaskServiceImpl.setVariable(taskId, variableName, value): a null variableName is rejected before SetTaskVariablesCmd runs. Note taskId itself is validated later inside the command, but the variable name must be non-null here.","triggerScenarios":"Calling cmmnTaskService.setVariable(taskId, null, value) — typically when the variable name comes from a map key, header, or user input that was null.","commonSituations":"Iterating a Map with null keys or building variables from request payloads with missing names; a variable-name constant that was renamed/removed; dynamic variable names computed from case data.","solutions":["Validate variableName is a non-empty string before calling setVariable","Fix the data source producing null names (payload validation, map iteration)","Use Objects.requireNonNull(variableName) early with a clear message at the caller"],"exampleFix":"// before\ncmmnTaskService.setVariable(taskId, request.getVarName(), value);\n// after\nString name = request.getVarName();\nif (name != null && !name.isEmpty()) {\n    cmmnTaskService.setVariable(taskId, name, value);\n}","handlingStrategy":"validation","validationCode":"if (variableName == null || variableName.isEmpty()) throw new IllegalArgumentException(\"variableName required\");","typeGuard":null,"tryCatchPattern":"try { taskService.setVariable(taskId, name, value); } catch (FlowableIllegalArgumentException e) { /* null name */ }","preventionTips":["Validate incoming request payloads for variable names","Skip null-key entries when copying maps of variables","Define variable names as constants to avoid nulls"],"tags":["java","variables","null-check","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-14T11:17:12.474Z"}