flowable/flowable-engine · error · FlowableIllegalArgumentException

Cannot combine withoutTaskId() with task(String) or…

Error message

Cannot combine withoutTaskId() with task(String) or taskIds(Collection) in the same query

What it means

InternalVariableInstanceQueryImpl.withoutTaskId() throws FlowableIllegalArgumentException when taskId or taskIds was already set on the same query. 'Has no task' and 'belongs to specific task(s)' are contradictory filters, so the builder rejects the combination at construction time.

Solutions

  1. Call withoutTaskId() only on a fresh query with no task filters set
  2. Restructure filter assembly so task-scoped and task-less queries are separate branches
  3. Create two distinct queries if both result sets are required

Example fix

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

Strategy: validation

Validate before calling

boolean conflict = useWithoutTaskId && (taskId != null || (taskIds != null && !taskIds.isEmpty())); if (conflict) throw new IllegalStateException("withoutTaskId cannot combine with taskId/taskIds");

Try / catch

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

Prevention

When it happens

Trigger: Calling withoutTaskId() on a query where taskId(String) or taskIds(Collection) was already called on the same builder instance.

Common situations: Reusable query builders shared across code paths; conditional assembly where a task filter was added earlier and a later branch also enables withoutTaskId(); copy-paste filter chains.

Related errors


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

Appendix: source

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

            throw new FlowableIllegalArgumentException("executionId is empty");
        }
        this.executionId = executionId;
        return this;
    }

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

    @Override
    public InternalVariableInstanceQuery withoutTaskId() {
        if (taskId != null || taskIds != null) {
            throw new FlowableIllegalArgumentException("Cannot combine withoutTaskId() with task(String) or taskIds(Collection) in the same query");
        }
        this.withoutTaskId = true;
        return this;
    }

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

    @Override
    public InternalVariableInstanceQuery scopeIds(Collection<String> scopeIds) {
        this.scopeIds = scopeIds;
        return this;

View on GitHub (pinned to d6d39ce1c6)