{"record":{"id":"fa64d474e7d4fffc","repo":"flowable/flowable-engine","slug":"invalid-query-usage-cannot-set-both-tasknamein-an-fa64d4","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":"ActivitiIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/HistoricTaskInstanceQueryImpl.java","lineNumber":388,"sourceCode":"            this.taskName = taskName;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricTaskInstanceQuery taskNameIn(List<String> taskNameList) {\n        if (taskNameList == null) {\n            throw new ActivitiIllegalArgumentException(\"Task name list is null\");\n        }\n        if (taskNameList.isEmpty()) {\n            throw new ActivitiIllegalArgumentException(\"Task name list is empty\");\n        }\n\n        if (taskName != null) {\n            throw new ActivitiIllegalArgumentException(\"Invalid query usage: cannot set both taskNameIn and taskName\");\n        }\n        if (taskNameLike != null) {\n            throw new ActivitiIllegalArgumentException(\"Invalid query usage: cannot set both taskNameIn and taskNameLike\");\n        }\n        if (taskNameLikeIgnoreCase != null) {\n            throw new ActivitiIllegalArgumentException(\"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(List<String> taskNameList) {\n        if (taskNameList == null) {\n            throw new ActivitiIllegalArgumentException(\"Task name list is null\");\n        }","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/HistoricTaskInstanceQueryImpl.java#L370-L406","documentation":"taskNameIn conflicts with the LIKE-based filter taskNameLike. The taskNameIn setter rejects queries where taskNameLike was already set, since an exact IN list and a LIKE pattern cannot be combined for the same column in this query API.","triggerScenarios":"Calling .taskNameIn(List<String>) on a HistoricTaskInstanceQuery on which .taskNameLike(\"%review%\") was previously called.","commonSituations":"Dynamic query builders that add a pattern filter when the user types partial text, then also apply an IN list from a multi-select UI.","solutions":["Remove the .taskNameLike(...) call before calling taskNameIn, or use only taskNameLike.","Use taskNameInIgnoreCase instead if case-insensitive matching of the list was the intent behind taskNameLike.","Create a new query object instead of reusing one configured with taskNameLike."],"exampleFix":"// before\nquery.taskNameLike(\"%review%\");\nquery.taskNameIn(names);\n// after\nquery.taskNameInIgnoreCase(names); // or drop the like filter\nquery.taskNameIn(names);","handlingStrategy":"validation","validationCode":"if (names != null && !names.isEmpty()) {\n    // choose ONE: like-pattern OR in-list\n    if (pattern != null) {\n        query.taskNameLike(pattern);\n    } else {\n        query.taskNameIn(names);\n    }\n}","typeGuard":"boolean canUseTaskNameIn(HistoricTaskInstanceQueryImpl q) { return q.getTaskNameLike() == null; }","tryCatchPattern":"try {\n    query.taskNameIn(names);\n} catch (org.activiti.engine.ActivitiIllegalArgumentException e) {\n    // taskNameLike already set — drop it or use taskNameInIgnoreCase\n    throw new IllegalArgumentException(\"Choose either taskNameLike or taskNameIn\", e);\n}","preventionTips":["Decide per request whether filtering is exact-list or pattern-based, never both.","Document that taskNameLike and taskName*In* are exclusive on the name column.","Add a unit test covering each invalid combination."],"tags":["flowable","query","invalid-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"}