flowable/flowable-engine · error · FlowableIllegalArgumentException

Invalid query usage: cannot set both taskNameIn and nameLike

Error message

Invalid query usage: cannot set both taskNameIn and nameLike

What it means

Thrown by TaskQuery.taskNameIn(Collection) when taskNameLike(String) was already set on the query. An IN-list and a LIKE pattern are alternative name-matching criteria; Flowable forbids combining them so the resulting SQL WHERE clause stays unambiguous. It is raised immediately at query-build time as FlowableIllegalArgumentException.

Solutions

  1. Drop either taskNameLike(...) or taskNameIn(...) — pick one matching strategy for the name
  2. If both are needed, issue two separate queries (one LIKE, one IN) and union the results in application code
  3. Rebuild the TaskQuery from scratch instead of mutating a shared instance

Example fix

// before
taskQuery.taskNameLike("Approv%")
         .taskNameIn(Arrays.asList("Approve", "Rejected"));
// after
taskQuery.taskNameLike("Approv%");
Defensive patterns

Strategy: validation

Validate before calling

if (nameLike != null && nameList != null) {
    throw new IllegalArgumentException("Use either taskNameLike or taskNameIn, not both");
}

Try / catch

try {
    taskService.createTaskQuery().taskNameIn(names).list();
} catch (FlowableIllegalArgumentException e) {
    // fall back to a single-criterion query
}

Prevention

When it happens

Trigger: Calling taskQuery.taskNameLike("Approv%") followed by taskQuery.taskNameIn(names) (or vice versa) on the same query or inside the same or() block; the check fires whenever the internal nameLike field is non-null.

Common situations: Merging user filter preferences where one screen sets a wildcard search and another sets a multi-select list; incremental query building where an earlier code path chose taskNameLike; copy-paste between two query builders.

Related errors


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

Appendix: source

Thrown at modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/TaskQueryImpl.java:268

    @Override
    public TaskQuery taskNameIn(Collection<String> nameList) {
        if (nameList == null) {
            throw new FlowableIllegalArgumentException("Task name list is null");
        }
        if (nameList.isEmpty()) {
            throw new FlowableIllegalArgumentException("Task name list is empty");
        }
        for (String name : nameList) {
            if (name == null) {
                throw new FlowableIllegalArgumentException("None of the given task names can be null");
            }
        }

        if (name != null) {
            throw new FlowableIllegalArgumentException("Invalid query usage: cannot set both taskNameIn and name");
        }
        if (nameLike != null) {
            throw new FlowableIllegalArgumentException("Invalid query usage: cannot set both taskNameIn and nameLike");
        }
        if (nameLikeIgnoreCase != null) {
            throw new FlowableIllegalArgumentException("Invalid query usage: cannot set both taskNameIn and nameLikeIgnoreCase");
        }

        if (orActive) {
            currentOrQueryObject.nameList = nameList;
        } else {
            this.nameList = nameList;
        }
        return this;
    }

    @Override
    public TaskQuery taskNameInIgnoreCase(Collection<String> nameList) {
        if (nameList == null) {
            throw new FlowableIllegalArgumentException("Task name list is null");
        }

View on GitHub (pinned to d6d39ce1c6)