{"record":{"id":"2d9a874c9f2321a4","repo":"flowable/flowable-engine","slug":"variablename-is-null-2d9a87","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/RuntimeServiceImpl.java","lineNumber":359,"sourceCode":"    @Override\n    public VariableInstance getVariableInstanceLocal(String executionId, String variableName) {\n        return commandExecutor.execute(new GetExecutionVariableInstanceCmd(executionId, variableName, true));\n    }\n\n    @Override\n    public <T> T getVariableLocal(String executionId, String variableName, Class<T> variableClass) {\n        return variableClass.cast(getVariableLocal(executionId, variableName));\n    }\n\n    @Override\n    public boolean hasVariableLocal(String executionId, String variableName) {\n        return commandExecutor.execute(new HasExecutionVariableCmd(executionId, variableName, true));\n    }\n\n    @Override\n    public void setVariable(String executionId, 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 SetExecutionVariablesCmd(executionId, variables, false));\n    }\n\n    @Override\n    public void setVariableLocal(String executionId, 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 SetExecutionVariablesCmd(executionId, variables, true));\n    }\n\n    @Override\n    public void setVariables(String executionId, Map<String, ?> variables) {","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/RuntimeServiceImpl.java#L341-L377","documentation":"RuntimeServiceImpl.setVariable(String executionId, String variableName, Object value) validates that variableName is non-null before dispatching SetExecutionVariablesCmd. Flowable throws FlowableIllegalArgumentException because a process variable cannot exist without a name; the null name would fail deep inside variable persistence with a less clear error.","triggerScenarios":"Calling runtimeService.setVariable(executionId, null, value), typically when the variable name comes from config, a map iteration that yields null keys, or external input with missing 'name' fields.","commonSituations":"Deserializing variable definitions from JSON where the name field is absent; dynamic variable setting driven by user input; refactor renamed the variable constant and a reference became null.","solutions":["Ensure variableName is non-null before calling setVariable","Validate external/config-sourced variable names early (at parse time)","Fix the source of the null name (missing map entry, unset constant, malformed payload)","Catch FlowableIllegalArgumentException at the API boundary and return a validation error to the caller"],"exampleFix":"// before\nruntimeService.setVariable(executionId, name, value); // name may be null\n// after\nObjects.requireNonNull(name, \"variableName must not be null\");\nruntimeService.setVariable(executionId, name, value);","handlingStrategy":"validation","validationCode":"if (variableName == null) {\n    throw new IllegalArgumentException(\"variableName must not be null before setVariable\");\n}","typeGuard":"boolean hasName = variableName != null && !variableName.isEmpty();","tryCatchPattern":"try {\n    runtimeService.setVariable(executionId, name, value);\n} catch (FlowableIllegalArgumentException e) {\n    log.error(\"Rejected variable set: {}\", e.getMessage());\n    throw new ValidationException(\"Variable name is required\");\n}","preventionTips":["Validate variable names at ingestion (REST payloads, config files)","Use constants/enums for variable names instead of raw strings","Guard map-driven variable setting against null keys","Add requireNonNull checks in wrapper/service layers"],"tags":["flowable","runtime-service","variables","null-argument"],"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"}