flowable/flowable-engine · error · FlowableIllegalArgumentException
variable name is null
Error message
variable name is null
What it means
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.
Source
Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetVariableCmd.java:51
public class SetVariableCmd implements Command<Void> {
protected String caseInstanceId;
protected String variableName;
protected Object variableValue;
public SetVariableCmd(String caseInstanceId, String variableName, Object variableValue) {
this.caseInstanceId = caseInstanceId;
this.variableName = variableName;
this.variableValue = variableValue;
}
@Override
public Void execute(CommandContext commandContext) {
if (caseInstanceId == null) {
throw new FlowableIllegalArgumentException("caseInstanceId is null");
}
if (variableName == null) {
throw new FlowableIllegalArgumentException("variable name is null");
}
CaseInstanceEntity caseInstanceEntity = CommandContextUtil.getCaseInstanceEntityManager(commandContext).findById(caseInstanceId);
if (caseInstanceEntity == null) {
throw new FlowableObjectNotFoundException("No case instance found for id " + caseInstanceId, CaseInstanceEntity.class);
}
caseInstanceEntity.setVariable(variableName, variableValue);
CmmnEngineAgenda agenda = CommandContextUtil.getAgenda(commandContext);
CmmnDeploymentManager deploymentManager = CommandContextUtil.getCmmnEngineConfiguration(commandContext).getDeploymentManager();
CaseDefinition caseDefinition = deploymentManager.findDeployedCaseDefinitionById(caseInstanceEntity.getCaseDefinitionId());
boolean evaluateVariableEventListener = false;
if (caseDefinition != null) {
CmmnModel cmmnModel = deploymentManager.resolveCaseDefinition(caseDefinition).getCmmnModel();
for (Case caze : cmmnModel.getCases()) {
List<VariableEventListener> variableEventListeners = caze.findPlanItemDefinitionsOfType(VariableEventListener.class);
for (VariableEventListener variableEventListener : variableEventListeners) {View on GitHub (pinned to d6d39ce1c6)
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
Example fix
// before
cmmnRuntimeService.setVariable(caseId, name, value);
// after
if (name == null) throw new IllegalArgumentException("variable name required");
cmmnRuntimeService.setVariable(caseId, name, value); Defensive patterns
Strategy: validation
Validate before calling
if (variableName == null || variableName.trim().isEmpty()) {
throw new IllegalArgumentException("variableName must not be null or empty");
} Type guard
boolean hasVariableName(String name) { return name != null && !name.trim().isEmpty(); } Try / catch
try {
cmmnRuntimeService.setVariable(caseInstanceId, variableName, value);
} catch (FlowableIllegalArgumentException e) {
log.error("Invalid variable name: {}", e.getMessage());
} Prevention
- 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
When it happens
Trigger: Calling setVariable(caseInstanceId, null, value), or passing a name computed from data/config that resolved to null.
Common situations: Missing property in configuration, map lookup with absent key, refactoring removed the constant's value.
Related errors
- caseInstanceId is null
- variable name is null
- caseInstanceId is null
- caseInstanceId is null
- variables is null
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/945b1ee0e83746cb.
Report an issue: GitHub.