{"record":{"id":"acf9371ab0bac856","repo":"flowable/flowable-engine","slug":"invalid-query-usage-cannot-set-both-tasknamein-an-acf937","errorCode":null,"errorMessage":"Invalid query usage: cannot set both taskNameIn and name","messagePattern":"Invalid query usage: cannot set both taskNameIn and name","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/TaskQueryImpl.java","lineNumber":265,"sourceCode":"        return this;\n    }\n\n    @Override\n    public TaskQuery taskNameIn(Collection<String> nameList) {\n        if (nameList == null) {\n            throw new FlowableIllegalArgumentException(\"Task name list is null\");\n        }\n        if (nameList.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"Task name list is empty\");\n        }\n        for (String name : nameList) {\n            if (name == null) {\n                throw new FlowableIllegalArgumentException(\"None of the given task names can be null\");\n            }\n        }\n\n        if (name != null) {\n            throw new FlowableIllegalArgumentException(\"Invalid query usage: cannot set both taskNameIn and name\");\n        }\n        if (nameLike != null) {\n            throw new FlowableIllegalArgumentException(\"Invalid query usage: cannot set both taskNameIn and nameLike\");\n        }\n        if (nameLikeIgnoreCase != null) {\n            throw new FlowableIllegalArgumentException(\"Invalid query usage: cannot set both taskNameIn and nameLikeIgnoreCase\");\n        }\n\n        if (orActive) {\n            currentOrQueryObject.nameList = nameList;\n        } else {\n            this.nameList = nameList;\n        }\n        return this;\n    }\n\n    @Override\n    public TaskQuery taskNameInIgnoreCase(Collection<String> nameList) {","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/TaskQueryImpl.java#L247-L283","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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()"],"exampleFix":"// before\ntaskQuery.taskName(\"Review\")\n         .taskNameIn(Arrays.asList(\"Review\", \"Approve\"));\n// after\ntaskQuery.taskNameIn(Arrays.asList(\"Review\", \"Approve\"));","handlingStrategy":"validation","validationCode":"if (name != null && (nameList != null)) {\n    throw new IllegalArgumentException(\"Use either taskName or taskNameIn, not both\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    taskService.createTaskQuery().taskNameIn(names).list();\n} catch (FlowableIllegalArgumentException e) {\n    // rebuild query with a single name criterion\n}","preventionTips":["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"],"tags":["flowable","query-usage","task-query","mutually-exclusive"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}