{"record":{"id":"945b1ee0e83746cb","repo":"flowable/flowable-engine","slug":"variable-name-is-null-945b1e","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/SetVariableCmd.java","lineNumber":51,"sourceCode":"public class SetVariableCmd implements Command<Void> {\n    \n    protected String caseInstanceId;\n    protected String variableName;\n    protected Object variableValue;\n    \n    public SetVariableCmd(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        CaseInstanceEntity caseInstanceEntity = CommandContextUtil.getCaseInstanceEntityManager(commandContext).findById(caseInstanceId);\n        if (caseInstanceEntity == null) {\n            throw new FlowableObjectNotFoundException(\"No case instance found for id \" + caseInstanceId, CaseInstanceEntity.class);\n        }\n        caseInstanceEntity.setVariable(variableName, variableValue);\n        \n        CmmnEngineAgenda agenda = CommandContextUtil.getAgenda(commandContext);\n        \n        CmmnDeploymentManager deploymentManager = CommandContextUtil.getCmmnEngineConfiguration(commandContext).getDeploymentManager();\n        CaseDefinition caseDefinition = deploymentManager.findDeployedCaseDefinitionById(caseInstanceEntity.getCaseDefinitionId());\n        boolean evaluateVariableEventListener = false;\n        if (caseDefinition != null) {\n            CmmnModel cmmnModel = deploymentManager.resolveCaseDefinition(caseDefinition).getCmmnModel();\n            for (Case caze : cmmnModel.getCases()) {\n                List<VariableEventListener> variableEventListeners = caze.findPlanItemDefinitionsOfType(VariableEventListener.class);\n                for (VariableEventListener variableEventListener : variableEventListeners) {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetVariableCmd.java#L33-L69","documentation":"Thrown by SetVariableCmd.execute when variableName is null. The command validates arguments before loading the case instance; a null name cannot be stored as a variable and is rejected with FlowableIllegalArgumentException.","triggerScenarios":"Calling setVariable(caseInstanceId, null, value), or passing a name computed from data/config that resolved to null.","commonSituations":"Missing property in configuration, map lookup with absent key, refactoring removed the constant's value.","solutions":["Pass a valid non-null variableName","Guard the name at the call site before invoking the API","Correct the configuration/source that produced null"],"exampleFix":"// before\ncmmnRuntimeService.setVariable(caseId, name, value);\n// after\nif (name == null) throw new IllegalArgumentException(\"variable name required\");\ncmmnRuntimeService.setVariable(caseId, name, 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.setVariable(caseInstanceId, variableName, value);\n} catch (FlowableIllegalArgumentException e) {\n    log.error(\"Invalid variable name: {}\", e.getMessage());\n}","preventionTips":["Use constants/enums for variable names instead of ad-hoc strings","Validate names loaded from external config before use","Include variable-name null checks in unit tests"],"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"}