flowable/flowable-engine · error · FlowableIllegalArgumentException
caseInstanceId is null
Error message
caseInstanceId is null
What it means
Thrown by SetVariableAsyncCmd.execute when the caseInstanceId passed to the async set-variable command is null. Flowable validates required arguments up front and rejects null ids with FlowableIllegalArgumentException rather than doing a DB lookup.
Source
Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetVariableAsyncCmd.java:38
import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;
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
- Ensure caseInstanceId is populated before calling setVariableAsync
- Validate the id string is non-null/non-empty at the call site
- Trace where the id comes from; fix the upstream query that returned null
Example fix
// before cmmnRuntimeService.setVariableAsync(caseInstanceId, "status", "done"); // caseInstanceId may be null // after Objects.requireNonNull(caseInstanceId, "caseInstanceId must not be null"); cmmnRuntimeService.setVariableAsync(caseInstanceId, "status", "done");
Defensive patterns
Strategy: validation
Validate before calling
if (caseInstanceId == null || caseInstanceId.trim().isEmpty()) {
throw new IllegalArgumentException("caseInstanceId must not be null or empty");
} Type guard
boolean hasCaseInstanceId(String id) { return id != null && !id.trim().isEmpty(); } Try / catch
try {
cmmnRuntimeService.setVariableAsync(caseInstanceId, name, value);
} catch (FlowableIllegalArgumentException e) {
log.error("Invalid argument for setVariableAsync: {}", e.getMessage());
} Prevention
- Capture the returned case instance id at case start and pass it explicitly
- Validate ids at service/REST boundaries before invoking engine commands
- Avoid nullable id fields in code paths that reach the engine
When it happens
Trigger: Calling setVariableAsync (or building SetVariableAsyncCmd) without setting caseInstanceId, e.g. from code where the case instance id variable is null or a lookup returned null and wasn't checked.
Common situations: A previous query returned null and its result was passed straight through, builder fields forgotten, or an API/REST layer dropped the parameter.
Related errors
- variable name is null
- caseInstanceId is null
- variable name is null
- caseInstanceId is null
- variables is null
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/bd83fd30f4d3ff47.
Report an issue: GitHub.