Activiti/Activiti · error · ActivitiIllegalArgumentException
Invalid query usage: cannot set both taskNameInIgnoreCase…
Error message
Invalid query usage: cannot set both taskNameInIgnoreCase and name
What it means
A TaskQuery allows only one name-matching criterion at a time. If taskName was already set and the caller then invokes taskNameInIgnoreCase, Activiti throws ActivitiIllegalArgumentException because the two filters are mutually exclusive and cannot be combined into valid SQL. This is query-usage validation shared by all TaskQueryImpl criteria setters.
Solutions
- Choose one criterion: call either taskName or taskNameInIgnoreCase, never both, per query instance.
- Restructure conditional builder code so only one name branch executes (if/else, not sequential adds).
- Build a fresh TaskQuery per request instead of mutating a shared one.
- If both names must match, merge them into the single taskNameInIgnoreCase list.
Example fix
// before
query.taskName(name);
query.taskNameInIgnoreCase(names);
// after
if (names != null && !names.isEmpty()) {
query.taskNameInIgnoreCase(names);
} else if (name != null) {
query.taskName(name);
} Defensive patterns
Strategy: validation
Validate before calling
if (name != null && names != null) { throw new IllegalStateException("Use either taskName or taskNameInIgnoreCase, not both"); } Try / catch
try {
buildQuery(name, names);
} catch (org.activiti.engine.ActivitiIllegalArgumentException e) {
if (e.getMessage().contains("Invalid query usage")) {
throw new BadRequestException("Conflicting task name filters");
}
throw e;
} Prevention
- Track which name criterion is set in your query-builder wrapper.
- Use if/else branches, not sequential setter calls, for alternative filters.
- Never mutate and reuse a shared TaskQuery instance.
- Prefer a single taskNameInIgnoreCase list over mixing single and list filters.
When it happens
Trigger: taskQuery.taskName("x").taskNameInIgnoreCase(Arrays.asList("y")) — any call order where both name filters end up set on the same query object (name vs taskNameInIgnoreCase).
Common situations: Conditional query building where one branch sets taskName and another later unconditionally adds taskNameInIgnoreCase; reusing a cached/pre-built query object and appending more filters; OR-query fragments accidentally combined with the main query criteria.
Related errors
- Invalid query usage: cannot set both taskNameInIgnoreCase…
- Invalid query usage: cannot set both taskNameInIgnoreCase…
- Description is null
- Task descriptionlike is null
- Task descriptionLikeIgnoreCase is null
AI-assisted analysis of Activiti/Activiti@56435b1a97 (2026-09-09).
Data as JSON: /api/errors/fa4012e97a2e3d96.
Report an issue: GitHub.
Appendix: source
Thrown at activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/TaskQueryImpl.java:211
return this;
}
@Override
public TaskQuery taskNameInIgnoreCase(List<String> nameList) {
if (nameList == null) {
throw new ActivitiIllegalArgumentException("Task name list is null");
}
if (nameList.isEmpty()) {
throw new ActivitiIllegalArgumentException("Task name list is empty");
}
for (String name : nameList) {
if (name == null) {
throw new ActivitiIllegalArgumentException("None of the given task names can be null");
}
}
if (name != null) {
throw new ActivitiIllegalArgumentException(
"Invalid query usage: cannot set both taskNameInIgnoreCase and name"
);
}
if (nameLike != null) {
throw new ActivitiIllegalArgumentException(
"Invalid query usage: cannot set both taskNameInIgnoreCase and nameLike"
);
}
if (nameLikeIgnoreCase != null) {
throw new ActivitiIllegalArgumentException(
"Invalid query usage: cannot set both taskNameInIgnoreCase and nameLikeIgnoreCase"
);
}
final int nameListSize = nameList.size();
final List<String> caseIgnoredNameList = new ArrayList<String>(nameListSize);
for (String name : nameList) {
caseIgnoredNameList.add(name.toLowerCase());View on GitHub (pinned to 56435b1a97)