flowable/flowable-engine · error · FlowableIllegalArgumentException
caseInstanceId is null
Error message
caseInstanceId is null
What it means
GetVariablesCmd.execute throws FlowableIllegalArgumentException when the caseInstanceId passed to the command is null. The CMMN engine cannot look up variables without knowing which case instance they belong to, so it fails fast before querying the variable store.
Source
Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetVariablesCmd.java:44
import org.flowable.variable.service.impl.persistence.entity.VariableInstanceEntity;
/**
* @author Joram Barrez
*/
public class GetVariablesCmd implements Command<Map<String, Object>> {
protected String caseInstanceId;
protected Collection<String> variableNames;
public GetVariablesCmd(String caseInstanceId, Collection<String> variableNames) {
this.caseInstanceId = caseInstanceId;
this.variableNames = variableNames;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
if (caseInstanceId == null) {
throw new FlowableIllegalArgumentException("caseInstanceId is null");
}
CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
List<VariableInstanceEntity> variableInstanceEntities;
if (variableNames == null || variableNames.isEmpty()) {
variableInstanceEntities = cmmnEngineConfiguration.getVariableServiceConfiguration().getVariableService()
.findVariableInstanceByScopeIdAndScopeType(caseInstanceId, ScopeTypes.CMMN);
} else {
variableInstanceEntities = cmmnEngineConfiguration.getVariableServiceConfiguration().getVariableService()
.createInternalVariableInstanceQuery()
.scopeId(caseInstanceId)
.withoutSubScopeId()
.scopeType(ScopeTypes.CMMN)
.names(variableNames)
.list();
}
Map<String, Object> variables = new HashMap<>(variableInstanceEntities.size());View on GitHub (pinned to d6d39ce1c6)
Solutions
- Ensure the caseInstanceId value is non-null before calling getVariables; log/inspect where the id comes from
- Load the case instance first via cmmnRuntimeService.createCaseInstanceQuery().caseInstanceBusinessKey(...).singleResult() and check for null
- If the id may legitimately be absent, guard the call site before invoking the command
Example fix
// before
Map<String, Object> vars = cmmnRuntimeService.getVariables(caseInstanceId);
// after
if (caseInstanceId == null) {
throw new IllegalStateException("No case instance id available");
}
Map<String, Object> vars = cmmnRuntimeService.getVariables(caseInstanceId); Defensive patterns
Strategy: validation
Validate before calling
if (caseInstanceId == null || caseInstanceId.isEmpty()) {
throw new IllegalArgumentException("caseInstanceId must be provided before fetching variables");
} Type guard
boolean hasCaseInstanceId(String id) {
return id != null && !id.trim().isEmpty();
} Try / catch
try {
Map<String, Object> vars = cmmnRuntimeService.getVariables(caseInstanceId);
} catch (FlowableIllegalArgumentException e) {
if (e.getMessage().contains("caseInstanceId is null")) {
// recover: skip variable fetch or re-resolve the id
} else {
throw e;
}
} Prevention
- Always obtain ids from query results and null-check singleResult() before use
- Wrap engine calls in a small facade that validates ids
- Avoid passing ids through chains of nullable fields; use Optional
When it happens
Trigger: Calling cmmnRuntimeService.getVariables(null) or getVariables(null, variableNames), or programmatically constructing GetVariablesCmd with a null caseInstanceId (e.g. a variable holding the id was never assigned or an earlier lookup returned null).
Common situations: Passing the result of a previous API call that returned null instead of throwing (e.g. missing case instance), copying a wrong variable from process context, or invoking the command from custom code where the id string was never populated.
Related errors
- planItemInstanceId is null
- planItemInstanceId is null
- variableName is null
- planItemInstanceId is null
- caseInstanceId is null
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/b5abcdffdaf690dd.
Report an issue: GitHub.