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

  1. Call only one of subScopeId(...) or withoutSubScopeId() per query.
  2. Clear/rebuild the query object before applying a different filtering mode.
  3. 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

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


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)