flowable/flowable-engine · error · FlowableIllegalArgumentException
caseInstanceId is null
Error message
caseInstanceId is null
What it means
RemoveVariableCmd removes a single variable from a CMMN case instance. It validates its inputs first and throws FlowableIllegalArgumentException when caseInstanceId is null, because removing a variable requires a target case instance.
Solutions
- Ensure caseInstanceId is non-null before invoking; fail fast at the caller
- Load the case instance first and use the returned entity's id
- Add an explicit null guard or Objects.requireNonNull with a clear message
- If the id comes from a request, validate it as required input
Example fix
// before cmmnRuntimeService.removeVariable(caseInstanceId, variableName); // caseInstanceId may be null // after Objects.requireNonNull(caseInstanceId, "caseInstanceId must not be null"); cmmnRuntimeService.removeVariable(caseInstanceId, variableName);
Defensive patterns
Strategy: validation
Validate before calling
if (caseInstanceId == null) throw new IllegalArgumentException("caseInstanceId is required"); Try / catch
try { cmmnRuntimeService.removeVariable(id, name); } catch (FlowableIllegalArgumentException e) { log.error("Invalid input: {}", e.getMessage()); } Prevention
- Validate required ids at the API boundary
- Fail fast on null results from lookups instead of forwarding them
- Use Objects.requireNonNull on engine-facing parameters
When it happens
Trigger: Passing null as the caseInstanceId argument to the remove-variable command / RuntimeService API, typically when an upstream lookup returned null and the result was forwarded unchecked.
Common situations: caseInstance singleResult() returned null (not found) and code did caseInstance.getId() style chains with nullable ids; optional request parameters bound to null in REST controllers.
Related errors
- caseInstanceId is null
- caseInstanceId is null
- caseInstanceId is null
- caseInstanceId is null
- caseInstanceId is null
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/d6240c22c89abf8c.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/RemoveVariableCmd.java:38
import org.flowable.common.engine.impl.interceptor.CommandContext;
/**
* @author Joram Barrez
*/
public class RemoveVariableCmd implements Command<Void> {
protected String caseInstanceId;
protected String variableName;
public RemoveVariableCmd(String caseInstanceId, String variableName) {
this.caseInstanceId = caseInstanceId;
this.variableName = variableName;
}
@Override
public Void execute(CommandContext commandContext) {
if (caseInstanceId == null) {
throw new FlowableIllegalArgumentException("caseInstanceId is null");
}
if (variableName == null) {
throw new FlowableIllegalArgumentException("variableName 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.removeVariable(variableName);
return null;
}
}
View on GitHub (pinned to d6d39ce1c6)