flowable/flowable-engine · error · FlowableIllegalArgumentException
Invalid query usage: cannot set both taskNameIn and name
Error message
Invalid query usage: cannot set both taskNameIn and name
What it means
This FlowableIllegalArgumentException is thrown by TaskQuery.taskNameIn(Collection) when a task name was already set via taskName(String). The task query API allows only one name-matching criterion per query (or per OR block), because name equality and an IN list are mutually exclusive in the generated SQL. The library fails fast at query-construction time rather than producing an ambiguous WHERE clause.
Solutions
- Remove one of the conflicting calls: keep either taskName(...) or taskNameIn(...) for the query (or within the same or() block)
- If both filters must be logically combined, split them into two queries and merge results, or use or() blocks on criteria other than the name fields
- Reset/rebuild the query object instead of reusing one that already has taskName set
- Validate your filter-building code so only one name criterion is populated before executeList()
Example fix
// before
taskQuery.taskName("Review")
.taskNameIn(Arrays.asList("Review", "Approve"));
// after
taskQuery.taskNameIn(Arrays.asList("Review", "Approve")); Defensive patterns
Strategy: validation
Validate before calling
if (name != null && (nameList != null)) {
throw new IllegalArgumentException("Use either taskName or taskNameIn, not both");
} Try / catch
try {
taskService.createTaskQuery().taskNameIn(names).list();
} catch (FlowableIllegalArgumentException e) {
// rebuild query with a single name criterion
} Prevention
- Set only one name criterion per query (or per or() block)
- Centralize task-filter building in one helper that enforces the mutual exclusivity
- Never reuse a mutated TaskQuery instance across code paths; build fresh queries
When it happens
Trigger: Calling taskQuery.taskName("foo") and later taskQuery.taskNameIn(List.of("a","b")) on the same query object; or building a query from merged/fallback filter options where both name and nameIn end up non-null; note the check compares against the shared `name` field, so taskName() called earlier anywhere on the query triggers it.
Common situations: Building dynamic task filters from user-supplied search criteria where 'exact name' and 'name in list' options are both populated; copying settings from a template query then adding taskNameIn; reusing a TaskQueryImpl instance across requests without resetting criteria.
Related errors
- Invalid query usage: cannot set both taskAssigneeIds and…
- Invalid query usage: cannot set both taskAssigneeIds and…
- Invalid query usage: cannot set both taskAssigneeIds and…
- Invalid query usage: cannot set both taskNameIn and…
- Invalid query usage: cannot set both taskNameIn and nameLike
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/acf9371ab0bac856.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/TaskQueryImpl.java:265
return this;
}
@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) {View on GitHub (pinned to d6d39ce1c6)