flowable/flowable-engine · error · FlowableIllegalArgumentException
Cannot combine withoutSubScopeId() with subScopeId(String)…
Error message
Cannot combine withoutSubScopeId() with subScopeId(String) in the same query
What it means
InternalVariableInstanceQueryImpl throws this when withoutSubScopeId() is called after subScopeId(String) has already been set. The two filters contradict each other (match a specific subScopeId vs match no subScopeId), so the query refuses the combination.
Solutions
- Call only one of subScopeId(...) or withoutSubScopeId() per query.
- Clear/rebuild the query object before applying a different filtering mode.
- Track which filters were applied and skip withoutSubScopeId() when subScopeId is present.
Example fix
// before
query.subScopeId("subScope-1");
query.withoutSubScopeId(); // throws
// after
query.withoutSubScopeId(); // pick only one filter Defensive patterns
Strategy: validation
Validate before calling
if (subScopeId != null && wantWithoutSubScope) {
throw new IllegalStateException("Choose either subScopeId or withoutSubScopeId, not both");
} Prevention
- Track applied filters and skip withoutSubScopeId() when subScopeId is set.
- Use if/else instead of sequential optional calls.
- Create a new query when switching filter mode.
When it happens
Trigger: Calling query.subScopeId("id") followed by query.withoutSubScopeId(); guard at InternalVariableInstanceQueryImpl.java:170 checks the subScopeId field for non-null.
Common situations: Adding a fallback 'exclude scoped variables' call in generic filter code without knowing the caller already set subScopeId; reusing query objects across requests.
Related errors
- Cannot combine onlyTimers() with onlyMessages() in the same…
- Cannot combine onlyTimers() with onlyMessages() in the same…
- Cannot combine subScopeId(String) with withoutSubScopeId()…
- Cannot combine subScopeIds with withoutSubScopeId in the…
- Invalid query usage: cannot set both candidateGroupIn and…
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/ff9b1b5ef16503f6.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/InternalVariableInstanceQueryImpl.java:170
this.subScopeId = subScopeId;
return this;
}
@Override
public InternalVariableInstanceQuery subScopeIds(Collection<String> subScopeIds) {
if (withoutSubScopeId) {
throw new FlowableIllegalArgumentException("Cannot combine subScopeIds with withoutSubScopeId in the same query");
}
this.subScopeIds = subScopeIds;
return this;
}
@Override
public InternalVariableInstanceQuery withoutSubScopeId() {
if (subScopeId != null) {
throw new FlowableIllegalArgumentException("Cannot combine withoutSubScopeId() with subScopeId(String) in the same query");
}
this.withoutSubScopeId = true;
return this;
}
@Override
public InternalVariableInstanceQuery scopeType(String scopeType) {
if (StringUtils.isEmpty(scopeType)) {
throw new FlowableIllegalArgumentException("scopeType is empty");
}
this.scopeType = scopeType;
return this;
}
@Override
public InternalVariableInstanceQuery scopeTypes(Collection<String> scopeTypes) {
this.scopeTypes = scopeTypes;
return this;View on GitHub (pinned to d6d39ce1c6)