flowable/flowable-engine · error · ActivitiIllegalArgumentException
Invalid query usage: cannot set both taskNameIn and…
Error message
Invalid query usage: cannot set both taskNameIn and taskNameLikeIgnoreCase
What it means
taskNameIn also conflicts with taskNameLikeIgnoreCase. The setter validates that the case-insensitive LIKE filter is not already set, throwing ActivitiIllegalArgumentException when both are present on the same query.
Solutions
- Drop the taskNameLikeIgnoreCase call before applying taskNameIn — the IN list is exact, so a case-insensitive LIKE is redundant.
- Use taskNameInIgnoreCase for a case-insensitive exact list match instead of taskNameLikeIgnoreCase.
- Start a fresh query object rather than mutating one that already carries a filter.
Example fix
// before
query.taskNameLikeIgnoreCase("review%");
query.taskNameIn(names);
// after
query.taskNameInIgnoreCase(names); Defensive patterns
Strategy: validation
Validate before calling
if (names != null && !names.isEmpty()) {
if (caseInsensitivePattern) {
query.taskNameLikeIgnoreCase(pattern);
} else {
query.taskNameIn(names); // or taskNameInIgnoreCase
}
} Type guard
boolean canUseTaskNameIn(HistoricTaskInstanceQueryImpl q) { return q.getTaskNameLikeIgnoreCase() == null; } Try / catch
try {
query.taskNameIn(names);
} catch (org.activiti.engine.ActivitiIllegalArgumentException e) {
// taskNameLikeIgnoreCase already set — rebuild query with one name filter
query = taskService.createHistoricTaskInstanceQuery().taskNameInIgnoreCase(names);
} Prevention
- Use taskNameInIgnoreCase when the goal was case-insensitive matching, not taskNameLikeIgnoreCase.
- Reset or rebuild queries when switching filter strategies mid-request.
- Keep name-filter assignment in one helper method.
When it happens
Trigger: Calling .taskNameIn(List<String>) after .taskNameLikeIgnoreCase("review%") on the same HistoricTaskInstanceQuery.
Common situations: Search screens that default to case-insensitive partial matching but switch to exact multi-select matching without resetting the query object.
Related errors
- Invalid query usage: cannot set both taskNameIn and taskName
- Invalid query usage: cannot set both taskNameIn and…
- Invalid query usage: cannot set both taskNameInIgnoreCase…
- Invalid query usage: cannot set both taskNameInIgnoreCase…
- Invalid query usage: cannot set both taskNameInIgnoreCase…
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/e05e38228fb0ef8b.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/HistoricTaskInstanceQueryImpl.java:391
}
@Override
public HistoricTaskInstanceQuery taskNameIn(List<String> taskNameList) {
if (taskNameList == null) {
throw new ActivitiIllegalArgumentException("Task name list is null");
}
if (taskNameList.isEmpty()) {
throw new ActivitiIllegalArgumentException("Task name list is empty");
}
if (taskName != null) {
throw new ActivitiIllegalArgumentException("Invalid query usage: cannot set both taskNameIn and taskName");
}
if (taskNameLike != null) {
throw new ActivitiIllegalArgumentException("Invalid query usage: cannot set both taskNameIn and taskNameLike");
}
if (taskNameLikeIgnoreCase != null) {
throw new ActivitiIllegalArgumentException("Invalid query usage: cannot set both taskNameIn and taskNameLikeIgnoreCase");
}
if (inOrStatement) {
currentOrQueryObject.taskNameList = taskNameList;
} else {
this.taskNameList = taskNameList;
}
return this;
}
@Override
public HistoricTaskInstanceQuery taskNameInIgnoreCase(List<String> taskNameList) {
if (taskNameList == null) {
throw new ActivitiIllegalArgumentException("Task name list is null");
}
if (taskNameList.isEmpty()) {
throw new ActivitiIllegalArgumentException("Task name list is empty");
}View on GitHub (pinned to d6d39ce1c6)