flowable/flowable-engine · error · org.flowable.common.engine.api.FlowableIllegalArgumentException

Cannot combine taskId(String) with withoutTaskId() in the…

Error message

Cannot combine taskId(String) with withoutTaskId() in the same query

What it means

InternalVariableInstanceQueryImpl.taskId(String) throws FlowableIllegalArgumentException when withoutTaskId was already set on the same query. The two filters are logically contradictory — 'match this exact task' versus 'match variables with no task' — so the query builder rejects the combination at construction time rather than returning confusing results.

Solutions

  1. Remove one of the two calls — keep either taskId(...) or withoutTaskId(), not both
  2. If both cases are needed, build two separate queries and merge results yourself
  3. Guard the builder code so the filters are mutually exclusive branches

Example fix

// before
query.withoutTaskId();
query.taskId(taskId); // throws
// after
if (taskId != null) {
    query.taskId(taskId);
} else {
    query.withoutTaskId();
}
Defensive patterns

Strategy: validation

Validate before calling

boolean conflicting = taskId != null && useWithoutTaskId; if (conflicting) throw new IllegalStateException("Choose taskId or withoutTaskId, not both");

Try / catch

try { buildQuery(taskId, withoutTaskId); } catch (FlowableIllegalArgumentException e) { throw new QueryConfigurationException(e.getMessage(), e); }

Prevention

When it happens

Trigger: Building a single InternalVariableInstanceQuery and calling taskId("someId") after (or before) withoutTaskId() on the same builder instance.

Common situations: Query-building code that conditionally adds filters; two code paths both mutating a shared query object; copy-paste of filter blocks adding both filters.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/0800a2cfced35fa7. Report an issue: GitHub.

Appendix: source

Thrown at modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/InternalVariableInstanceQueryImpl.java:72

    protected Collection<String> names;

    @Override
    public InternalVariableInstanceQuery id(String id) {
        if (StringUtils.isEmpty(id)) {
            throw new FlowableIllegalArgumentException("id is empty");
        }
        this.id = id;
        return this;
    }

    @Override
    public InternalVariableInstanceQuery taskId(String taskId) {
        if (StringUtils.isEmpty(taskId)) {
            throw new FlowableIllegalArgumentException("taskId is empty");
        }

        if (withoutTaskId) {
            throw new FlowableIllegalArgumentException("Cannot combine taskId(String) with withoutTaskId() in the same query");
        }

        this.taskId = taskId;
        return this;
    }

    @Override
    public InternalVariableInstanceQuery taskIds(Collection<String> taskIds) {
        if (taskIds == null || taskIds.isEmpty()) {
            throw new FlowableIllegalArgumentException("taskIds is null or empty");
        }

        if (withoutTaskId) {
            throw new FlowableIllegalArgumentException("Cannot combine taskIds(Collection) with withoutTaskId() in the same query");
        }
        this.taskIds = taskIds;
        return this;
    }

View on GitHub (pinned to d6d39ce1c6)