flowable/flowable-engine · error · FlowableIllegalArgumentException
variableName is null
Error message
variableName is null
What it means
GetTaskVariableInstanceCmd.execute() requires a variable name after validating taskId. If variableName is null it throws FlowableIllegalArgumentException('variableName is null'), since fetching a single variable instance is meaningless without knowing which variable to look up.
Solutions
- Pass a non-empty variableName string to getVariableInstance/getVariableInstanceLocal.
- Validate/trim the variable name parameter before invoking the task service.
- If iterating variables dynamically, use getVariableInstances(taskId) instead of per-name lookup.
Example fix
// before
VariableInstance vi = cmmnTaskService.getVariableInstance(taskId, config.get("varName"));
// after
String varName = config.get("varName");
if (varName == null || varName.isEmpty()) {
throw new IllegalArgumentException("varName must be configured");
}
VariableInstance vi = cmmnTaskService.getVariableInstance(taskId, varName); Defensive patterns
Strategy: validation
Validate before calling
if (variableName == null || variableName.trim().isEmpty()) { throw new IllegalArgumentException("variableName is required"); } Type guard
boolean hasVariableName(String name) { return name != null && !name.trim().isEmpty(); } Try / catch
try { return taskService.getVariableInstance(taskId, variableName); } catch (FlowableIllegalArgumentException e) { log.warn("Invalid variable lookup: {}", e.getMessage()); return null; } Prevention
- Define variable names as constants rather than literals/config lookups
- Validate external input (forms, requests) for required variable names
- Prefer getVariableInstances when names are dynamic
When it happens
Trigger: Calling cmmnTaskService.getVariableInstance(taskId, null) or getVariableInstanceLocal(taskId, null); a variable name sourced from config/UI that was never set.
Common situations: Variable name read from a properties file or request body with a missing key; typo where the name constant is null by initialization order; generic wrapper code that forwards a nullable name parameter.
Related errors
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/5565db8986547085.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetTaskVariableInstanceCmd.java:48
private static final long serialVersionUID = 1L;
protected String taskId;
protected String variableName;
protected boolean isLocal;
public GetTaskVariableInstanceCmd(String taskId, String variableName, boolean isLocal) {
this.taskId = taskId;
this.variableName = variableName;
this.isLocal = isLocal;
}
@Override
public VariableInstance execute(CommandContext commandContext) {
if (taskId == null) {
throw new FlowableIllegalArgumentException("taskId is null");
}
if (variableName == null) {
throw new FlowableIllegalArgumentException("variableName is null");
}
CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
TaskEntity task = cmmnEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId);
if (task == null) {
throw new FlowableObjectNotFoundException("task " + taskId + " doesn't exist", Task.class);
}
VariableInstance variableEntity;
if (isLocal) {
variableEntity = task.getVariableInstanceLocal(variableName, false);
} else {
variableEntity = task.getVariableInstance(variableName, false);
}
return variableEntity;View on GitHub (pinned to d6d39ce1c6)