{"record":{"id":"fa4012e97a2e3d96","repo":"Activiti/Activiti","slug":"invalid-query-usage-cannot-set-both-tasknameinign-fa4012","errorCode":null,"errorMessage":"Invalid query usage: cannot set both taskNameInIgnoreCase and name","messagePattern":"Invalid query usage: cannot set both taskNameInIgnoreCase and name","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/TaskQueryImpl.java","lineNumber":211,"sourceCode":"        return this;\n    }\n\n    @Override\n    public TaskQuery taskNameInIgnoreCase(List<String> nameList) {\n        if (nameList == null) {\n            throw new ActivitiIllegalArgumentException(\"Task name list is null\");\n        }\n        if (nameList.isEmpty()) {\n            throw new ActivitiIllegalArgumentException(\"Task name list is empty\");\n        }\n        for (String name : nameList) {\n            if (name == null) {\n                throw new ActivitiIllegalArgumentException(\"None of the given task names can be null\");\n            }\n        }\n\n        if (name != null) {\n            throw new ActivitiIllegalArgumentException(\n                \"Invalid query usage: cannot set both taskNameInIgnoreCase and name\"\n            );\n        }\n        if (nameLike != null) {\n            throw new ActivitiIllegalArgumentException(\n                \"Invalid query usage: cannot set both taskNameInIgnoreCase and nameLike\"\n            );\n        }\n        if (nameLikeIgnoreCase != null) {\n            throw new ActivitiIllegalArgumentException(\n                \"Invalid query usage: cannot set both taskNameInIgnoreCase and nameLikeIgnoreCase\"\n            );\n        }\n\n        final int nameListSize = nameList.size();\n        final List<String> caseIgnoredNameList = new ArrayList<String>(nameListSize);\n        for (String name : nameList) {\n            caseIgnoredNameList.add(name.toLowerCase());","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/Activiti/Activiti/blob/56435b1a97deeafdc09dd40074b056c89fba5a8a/activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/TaskQueryImpl.java#L193-L229","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nquery.taskName(name);\nquery.taskNameInIgnoreCase(names);\n// after\nif (names != null && !names.isEmpty()) {\n    query.taskNameInIgnoreCase(names);\n} else if (name != null) {\n    query.taskName(name);\n}","handlingStrategy":"validation","validationCode":"if (name != null && names != null) { throw new IllegalStateException(\"Use either taskName or taskNameInIgnoreCase, not both\"); }","typeGuard":null,"tryCatchPattern":"try {\n    buildQuery(name, names);\n} catch (org.activiti.engine.ActivitiIllegalArgumentException e) {\n    if (e.getMessage().contains(\"Invalid query usage\")) {\n        throw new BadRequestException(\"Conflicting task name filters\");\n    }\n    throw e;\n}","preventionTips":["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."],"tags":["java","activiti","task-query","mutually-exclusive"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"56435b1a97deeafdc09dd40074b056c89fba5a8a","analyzedAt":"2026-09-09T21:00:06.703Z","contentChangedAt":"2026-09-09T21:00:06.703Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}