flowable/flowable-engine · error · FlowableIllegalArgumentException
Case instance id is null
Error message
Case instance id is null
What it means
FlowableIllegalArgumentException thrown in AbstractNeedsCaseInstanceCmd.execute when the caseInstanceId field is null. The abstract command validates its required id argument before any database lookup, since a null id can never resolve. Any concrete command extending this class (e.g. changing case state, completing a form) inherits this guard.
Source
Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/AbstractNeedsCaseInstanceCmd.java:39
import org.flowable.common.engine.api.FlowableObjectNotFoundException;
import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;
/**
* @author Joram Barrez
*/
public abstract class AbstractNeedsCaseInstanceCmd implements Command<Void>, Serializable {
protected String caseInstanceId;
public AbstractNeedsCaseInstanceCmd(String caseInstanceId) {
this.caseInstanceId = caseInstanceId;
}
@Override
public Void execute(CommandContext commandContext) {
if (caseInstanceId == null) {
throw new FlowableIllegalArgumentException("Case instance id is null");
}
CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
CaseInstanceEntity caseInstanceEntity = cmmnEngineConfiguration.getCaseInstanceEntityManager().findById(caseInstanceId);
if (caseInstanceEntity == null) {
throw new FlowableObjectNotFoundException("Cannot find case instance for id " + caseInstanceId, CaseInstanceEntity.class);
}
internalExecute(commandContext, caseInstanceEntity);
return null;
}
protected abstract void internalExecute(CommandContext commandContext, CaseInstanceEntity caseInstanceEntity);
}
View on GitHub (pinned to d6d39ce1c6)
Solutions
- Validate the caseInstanceId at the caller level before invoking the CMMN runtime/task service API
- Log and reject requests that lack the case instance id parameter in your REST/controller layer
- Check the code path that produced the id (e.g. a previous query result) for null returns
- Use the correct constructor/builder overload that sets caseInstanceId
Example fix
// before
cmmnRuntimeService.caseInstanceStateChange(caseInstanceId, CaseInstanceState.TERMINATED); // caseInstanceId may be null
// after
if (caseInstanceId == null || caseInstanceId.isBlank()) {
throw new IllegalArgumentException("caseInstanceId must be provided");
}
cmmnRuntimeService.caseInstanceStateChange(caseInstanceId, CaseInstanceState.TERMINATED); Defensive patterns
Strategy: validation
Validate before calling
if (caseInstanceId == null || caseInstanceId.isBlank()) throw new IllegalArgumentException("caseInstanceId is required"); Type guard
boolean hasCaseInstanceId(String id) { return id != null && !id.isBlank(); } Try / catch
try { cmmnRuntimeService.caseInstanceStateChange(id, state); }
catch (FlowableIllegalArgumentException e) { log.error("Missing/invalid caseInstanceId: {}", e.getMessage()); } Prevention
- Validate required ids at the API/controller boundary
- Use Objects.requireNonNull on ids before engine calls
- Map optional REST parameters to a required 400 response, not null into the engine
- Keep id-creation and id-consumption paths in the same service layer
When it happens
Trigger: Calling a CMMN API such as runtimeService.trigger/case-state commands or task form commands with a null caseInstanceId argument; constructing the command object without setting the id; passing a variable that was never populated (e.g. missing request parameter mapped into the call).
Common situations: REST/HTTP layer where the caseInstanceId path/query parameter was absent and the null propagated into the service call; batch jobs processing lists where an entry lacks the id; misuse of a builder/constructor overload omitting the id.
Related errors
- caseInstanceId is null
- Cannot find case instance for id ${caseInstanceId}
- Plan item instance id is null
- taskId is null
- Cannot find case instance with id
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/b08df34b310bdc05.
Report an issue: GitHub.