{"record":{"id":"3c8d8dd35acbe054","repo":"flowable/flowable-engine","slug":"invalid-query-usage-cannot-set-both-tasknamein-an-3c8d8d","errorCode":null,"errorMessage":"Invalid query usage: cannot set both taskNameIn and taskNameLike","messagePattern":"Invalid query usage: cannot set both taskNameIn and taskNameLike","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/HistoricTaskInstanceQueryImpl.java","lineNumber":749,"sourceCode":"            this.taskName = taskName;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricTaskInstanceQuery taskNameIn(Collection<String> taskNameList) {\n        if (taskNameList == null) {\n            throw new FlowableIllegalArgumentException(\"Task name list is null\");\n        }\n        if (taskNameList.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"Task name list is empty\");\n        }\n\n        if (taskName != null) {\n            throw new FlowableIllegalArgumentException(\"Invalid query usage: cannot set both taskNameIn and taskName\");\n        }\n        if (taskNameLike != null) {\n            throw new FlowableIllegalArgumentException(\"Invalid query usage: cannot set both taskNameIn and taskNameLike\");\n        }\n        if (taskNameLikeIgnoreCase != null) {\n            throw new FlowableIllegalArgumentException(\"Invalid query usage: cannot set both taskNameIn and taskNameLikeIgnoreCase\");\n        }\n\n        if (inOrStatement) {\n            currentOrQueryObject.taskNameList = taskNameList;\n        } else {\n            this.taskNameList = taskNameList;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricTaskInstanceQuery taskNameInIgnoreCase(Collection<String> taskNameList) {\n        if (taskNameList == null) {\n            throw new FlowableIllegalArgumentException(\"Task name list is null\");\n        }","sourceCodeStart":731,"sourceCodeEnd":767,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/HistoricTaskInstanceQueryImpl.java#L731-L767","documentation":"HistoricTaskInstanceQueryImpl.taskNameIn(Collection) throws FlowableIllegalArgumentException when taskNameLike was already set on the same query. An exact-match IN list and a LIKE pattern filter on task name are mutually exclusive in Flowable's query model, so setting both is rejected as invalid query usage. Apply only one task-name filter per query.","triggerScenarios":"Calling historicTaskInstanceQuery().taskNameLike(\"rev%\").taskNameIn(List.of(\"review\")) — invoking taskNameIn after taskNameLike on the same query object, often through shared builder paths.","commonSituations":"Search UIs offering both 'name is one of' and 'name contains' filters where both options were submitted; generic query-assembly code that unconditionally sets a LIKE pattern plus an ID-list filter; conditional logic with a missing else branch.","solutions":["Set only one name filter: drop taskNameLike when taskNameIn is used (or vice versa).","Implement the 'either' logic explicitly: if a name list is present use taskNameIn, else if a pattern is present use taskNameLike.","Clear/reset the query object between filter assignments, or build a fresh query per request."],"exampleFix":"// before\nquery.taskNameLike(\"rev%\");\nquery.taskNameIn(Arrays.asList(\"review\")); // conflict\n// after\nif (names != null && !names.isEmpty()) {\n    query.taskNameIn(names);\n} else if (pattern != null) {\n    query.taskNameLike(pattern);\n}","handlingStrategy":"validation","validationCode":"if (pattern != null && names != null && !names.isEmpty()) {\n    throw new IllegalStateException(\"Use either taskNameLike or taskNameIn, not both\");\n}","typeGuard":"boolean nameFiltersCompatible(String taskName, String taskNameLike, Collection<String> taskNameIn) {\n    int set = (taskName != null ? 1 : 0) + (taskNameLike != null ? 1 : 0) + (taskNameIn != null && !taskNameIn.isEmpty() ? 1 : 0);\n    return set <= 1;\n}","tryCatchPattern":"try {\n    query.taskNameIn(names);\n} catch (FlowableIllegalArgumentException e) {\n    logger.warn(\"Conflicting task name filters: {}\", e.getMessage());\n}","preventionTips":["Branch explicitly: use taskNameIn when a list is present, otherwise taskNameLike when a pattern is present.","Keep filter selection logic in one place instead of accumulating setters on the query.","Cover combined-filter cases with unit tests using HistoricTaskInstanceQueryImpl directly."],"tags":["flowable","query-builder","conflicting-filters","invalid-query-usage"],"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"}