flowable/flowable-engine · error · FlowableIllegalArgumentException

variable name is null

Error message

variable name is null

What it means

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.

Source

Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetVariableAsyncCmd.java:41

public class SetVariableAsyncCmd extends AbstractSetVariableAsyncCmd implements Command<Void> {
    
    protected String caseInstanceId;
    protected String variableName;
    protected Object variableValue;
    
    public SetVariableAsyncCmd(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");
        }
     
        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
        CaseInstanceEntity caseInstanceEntity = cmmnEngineConfiguration.getCaseInstanceEntityManager().findById(caseInstanceId);
        if (caseInstanceEntity == null) {
            throw new FlowableObjectNotFoundException("No case instance found for id " + caseInstanceId, CaseInstanceEntity.class);
        }
        
        addVariable(false, caseInstanceId, null, variableName, variableValue, caseInstanceEntity.getTenantId(), 
                cmmnEngineConfiguration.getVariableServiceConfiguration().getVariableService());
        createSetAsyncVariablesJob(caseInstanceEntity, cmmnEngineConfiguration);
        
        return null;
    }

}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Supply a non-null variableName to setVariableAsync
  2. Validate the name before the call
  3. Fix the source (config key, map lookup) that yielded null

Example fix

// before
cmmnRuntimeService.setVariableAsync(caseId, varName, value);
// after
if (varName == null || varName.isEmpty()) throw new IllegalArgumentException("variable name required");
cmmnRuntimeService.setVariableAsync(caseId, varName, 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.setVariableAsync(caseInstanceId, variableName, value);
} catch (FlowableIllegalArgumentException e) {
    log.error("Invalid variable name: {}", e.getMessage());
}

Prevention

When it happens

Trigger: Calling setVariableAsync(caseInstanceId, null, value) or passing a name variable that was never initialized.

Common situations: Name read from config/JSON that is missing, refactoring renamed a constant to null, dynamic key computed from data that produced null.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/0f7a1aaad3b81758. Report an issue: GitHub.