flowable/flowable-engine · error · FlowableIllegalArgumentException
caseInstanceId is null
Error message
caseInstanceId is null
What it means
Thrown by SetVariableCmd.execute when caseInstanceId is null. Flowable's synchronous set-variable command validates its required arguments first and rejects a null case instance id with FlowableIllegalArgumentException before touching the database.
Source
Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetVariableCmd.java:48
/**
* @author Tijs Rademakers
*/
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();View on GitHub (pinned to d6d39ce1c6)
Solutions
- Populate caseInstanceId before invoking setVariable
- Add an explicit null/empty check at the call site
- Fix the upstream code path that produced the null id
Example fix
// before cmmnRuntimeService.setVariable(caseInstanceId, "k", "v"); // after Assert.hasText(caseInstanceId, "caseInstanceId required"); cmmnRuntimeService.setVariable(caseInstanceId, "k", "v");
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.setVariable(caseInstanceId, name, value);
} catch (FlowableIllegalArgumentException e) {
log.error("Invalid argument for setVariable: {}", e.getMessage());
} Prevention
- Validate required ids before calling engine commands
- Never propagate possibly-null ids from upstream lookups unchecked
- Add null checks in the layer that orchestrates case operations
When it happens
Trigger: Calling setVariable on the CMMN runtime service with a null id, e.g. the id variable is uninitialized or derived from a lookup that returned null.
Common situations: Case start result not captured, null returned by an earlier engine call and propagated, missing request parameter in a service layer.
Related errors
- caseInstanceId is null
- variable name 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/6c3e18e2c08340de.
Report an issue: GitHub.