{"record":{"id":"fcfa2413cf523d06","repo":"flowable/flowable-engine","slug":"invalid-query-usage-cannot-set-both-tasknamein-an-fcfa24","errorCode":null,"errorMessage":"Invalid query usage: cannot set both taskNameIn and nameLike","messagePattern":"Invalid query usage: cannot set both taskNameIn and nameLike","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/TaskQueryImpl.java","lineNumber":268,"sourceCode":"    @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) {\n        if (nameList == null) {\n            throw new FlowableIllegalArgumentException(\"Task name list is null\");\n        }","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/TaskQueryImpl.java#L250-L286","documentation":"Thrown by TaskQuery.taskNameIn(Collection) when taskNameLike(String) was already set on the query. An IN-list and a LIKE pattern are alternative name-matching criteria; Flowable forbids combining them so the resulting SQL WHERE clause stays unambiguous. It is raised immediately at query-build time as FlowableIllegalArgumentException.","triggerScenarios":"Calling taskQuery.taskNameLike(\"Approv%\") followed by taskQuery.taskNameIn(names) (or vice versa) on the same query or inside the same or() block; the check fires whenever the internal nameLike field is non-null.","commonSituations":"Merging user filter preferences where one screen sets a wildcard search and another sets a multi-select list; incremental query building where an earlier code path chose taskNameLike; copy-paste between two query builders.","solutions":["Drop either taskNameLike(...) or taskNameIn(...) — pick one matching strategy for the name","If both are needed, issue two separate queries (one LIKE, one IN) and union the results in application code","Rebuild the TaskQuery from scratch instead of mutating a shared instance"],"exampleFix":"// before\ntaskQuery.taskNameLike(\"Approv%\")\n         .taskNameIn(Arrays.asList(\"Approve\", \"Rejected\"));\n// after\ntaskQuery.taskNameLike(\"Approv%\");","handlingStrategy":"validation","validationCode":"if (nameLike != null && nameList != null) {\n    throw new IllegalArgumentException(\"Use either taskNameLike or taskNameIn, not both\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    taskService.createTaskQuery().taskNameIn(names).list();\n} catch (FlowableIllegalArgumentException e) {\n    // fall back to a single-criterion query\n}","preventionTips":["Decide a single matching strategy (exact, list, pattern) per name filter","Use a builder that clears conflicting fields before setting new ones","Keep wildcard (LIKE) and multi-select (IN) filters in mutually exclusive UI branches"],"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"}