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

  1. Choose one criterion: call either taskName or taskNameInIgnoreCase, never both, per query instance.
  2. Restructure conditional builder code so only one name branch executes (if/else, not sequential adds).
  3. Build a fresh TaskQuery per request instead of mutating a shared one.
  4. 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

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


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)