{"record":{"id":"0f7a1aaad3b81758","repo":"flowable/flowable-engine","slug":"variable-name-is-null-0f7a1a","errorCode":null,"errorMessage":"variable name is null","messagePattern":"variable name is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetVariableAsyncCmd.java","lineNumber":41,"sourceCode":"public class SetVariableAsyncCmd extends AbstractSetVariableAsyncCmd implements Command<Void> {\n    \n    protected String caseInstanceId;\n    protected String variableName;\n    protected Object variableValue;\n    \n    public SetVariableAsyncCmd(String caseInstanceId, String variableName, Object variableValue) {\n        this.caseInstanceId = caseInstanceId;\n        this.variableName = variableName;\n        this.variableValue = variableValue;\n    }\n    \n    @Override\n    public Void execute(CommandContext commandContext) {\n        if (caseInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"caseInstanceId is null\");\n        }\n        if (variableName == null) {\n            throw new FlowableIllegalArgumentException(\"variable name is null\");\n        }\n     \n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        CaseInstanceEntity caseInstanceEntity = cmmnEngineConfiguration.getCaseInstanceEntityManager().findById(caseInstanceId);\n        if (caseInstanceEntity == null) {\n            throw new FlowableObjectNotFoundException(\"No case instance found for id \" + caseInstanceId, CaseInstanceEntity.class);\n        }\n        \n        addVariable(false, caseInstanceId, null, variableName, variableValue, caseInstanceEntity.getTenantId(), \n                cmmnEngineConfiguration.getVariableServiceConfiguration().getVariableService());\n        createSetAsyncVariablesJob(caseInstanceEntity, cmmnEngineConfiguration);\n        \n        return null;\n    }\n\n}\n","sourceCodeStart":23,"sourceCodeEnd":58,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetVariableAsyncCmd.java#L23-L58","documentation":"Thrown by SetVariableAsyncCmd.execute when variableName is null. The async variable setter needs a non-null name to create the variable entry and schedules an async job afterwards; a null name is rejected with FlowableIllegalArgumentException before any persistence.","triggerScenarios":"Calling setVariableAsync(caseInstanceId, null, value) or passing a name variable that was never initialized.","commonSituations":"Name read from config/JSON that is missing, refactoring renamed a constant to null, dynamic key computed from data that produced null.","solutions":["Supply a non-null variableName to setVariableAsync","Validate the name before the call","Fix the source (config key, map lookup) that yielded null"],"exampleFix":"// before\ncmmnRuntimeService.setVariableAsync(caseId, varName, value);\n// after\nif (varName == null || varName.isEmpty()) throw new IllegalArgumentException(\"variable name required\");\ncmmnRuntimeService.setVariableAsync(caseId, varName, value);","handlingStrategy":"validation","validationCode":"if (variableName == null || variableName.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"variableName must not be null or empty\");\n}","typeGuard":"boolean hasVariableName(String name) { return name != null && !name.trim().isEmpty(); }","tryCatchPattern":"try {\n    cmmnRuntimeService.setVariableAsync(caseInstanceId, variableName, value);\n} catch (FlowableIllegalArgumentException e) {\n    log.error(\"Invalid variable name: {}\", e.getMessage());\n}","preventionTips":["Keep variable names as named constants, not computed nulls","Validate dynamic names derived from config or payloads before the call","Prefer empty-string checks too, since blank names are rarely intended"],"tags":["flowable","cmmn","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-14T05:17:10.506Z"}