{"record":{"id":"ba542b87127cf095","repo":"Activiti/Activiti","slug":"invalid-query-usage-cannot-set-both-taskassigneei-ba542b","errorCode":null,"errorMessage":"Invalid query usage: cannot set both taskAssigneeIds and taskAssigneeLike","messagePattern":"Invalid query usage: cannot set both taskAssigneeIds and taskAssigneeLike","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/TaskQueryImpl.java","lineNumber":395,"sourceCode":"        if (assigneeIds == null) {\n            throw new ActivitiIllegalArgumentException(\"Task assignee list is null\");\n        }\n        if (assigneeIds.isEmpty()) {\n            throw new ActivitiIllegalArgumentException(\"Task assignee list is empty\");\n        }\n        for (String assignee : assigneeIds) {\n            if (assignee == null) {\n                throw new ActivitiIllegalArgumentException(\"None of the given task assignees can be null\");\n            }\n        }\n\n        if (assignee != null) {\n            throw new ActivitiIllegalArgumentException(\n                \"Invalid query usage: cannot set both taskAssigneeIds and taskAssignee\"\n            );\n        }\n        if (assigneeLike != null) {\n            throw new ActivitiIllegalArgumentException(\n                \"Invalid query usage: cannot set both taskAssigneeIds and taskAssigneeLike\"\n            );\n        }\n        if (assigneeLikeIgnoreCase != null) {\n            throw new ActivitiIllegalArgumentException(\n                \"Invalid query usage: cannot set both taskAssigneeIds and taskAssigneeLikeIgnoreCase\"\n            );\n        }\n\n        if (orActive) {\n            currentOrQueryObject.assigneeIds = assigneeIds;\n        } else {\n            this.assigneeIds = assigneeIds;\n        }\n        return this;\n    }\n\n    public TaskQueryImpl taskOwner(String owner) {","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/Activiti/Activiti/blob/56435b1a97deeafdc09dd40074b056c89fba5a8a/activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/TaskQueryImpl.java#L377-L413","documentation":"This ActivitiIllegalArgumentException is thrown by TaskQueryImpl.taskAssigneeIds(List) when a task assignee-like filter was already set on the same query object. The task query API forbids combining assigneeIds with assignee/assigneeLike/assigneeLikeIgnoreCase because they target different DB column predicates and would produce an ambiguous SQL query. The library throws eagerly at query-build time to fail fast instead of generating broken SQL.","triggerScenarios":"Calling taskQuery.taskAssigneeLike(\"kermit%\").taskAssigneeIds(ids) (or the reverse order) on the same TaskQueryImpl instance, including inside an or() block where the same or-query object already holds assigneeLike.","commonSituations":"Building a dynamic task query where optional filters are applied conditionally and two branches both fired; migrating code from assigneeLike to the newer assigneeIds API and leaving the old call in place; copy-pasting query builder chains that mix assignee filter styles.","solutions":["Remove the taskAssigneeLike(...) call from the query when using taskAssigneeIds(...)","Pick one filter style: use assigneeIds for exact-id list matching, or assigneeLike/assigneeLikeIgnoreCase for pattern matching, not both","If both filters are genuinely needed, run two queries and merge results in application code","Guard conditional builder code so only one assignee-filter branch executes"],"exampleFix":"// before\nList<Task> tasks = taskService.createTaskQuery()\n    .taskAssigneeLike(\"kermit%\")\n    .taskAssigneeIds(ids)\n    .list();\n// after\nList<Task> tasks = taskService.createTaskQuery()\n    .taskAssigneeIds(ids)\n    .list();","handlingStrategy":"validation","validationCode":"if (assigneeIds != null && (assigneeLike != null || assigneeLikeIgnoreCase != null || assignee != null)) {\n    throw new IllegalArgumentException(\"Use either taskAssigneeIds or a single assignee pattern filter, not both\");\n}\ntaskService.createTaskQuery().taskAssigneeIds(assigneeIds);","typeGuard":"boolean canUseAssigneeIds(TaskQueryImpl q) {\n    return q.getAssignee() == null && q.getAssigneeLike() == null && q.getAssigneeLikeIgnoreCase() == null;\n}","tryCatchPattern":"try {\n    tasks = taskService.createTaskQuery().taskAssigneeIds(ids).list();\n} catch (ActivitiIllegalArgumentException e) {\n    if (e.getMessage().contains(\"taskAssigneeIds\")) {\n        tasks = taskService.createTaskQuery().taskAssigneeLike(pattern).list();\n    } else { throw e; }\n}","preventionTips":["Centralize task-query construction in one builder method so conflicting filters cannot be combined","Track which assignee filter style is active in a variable and assert before applying another","Prefer assigneeIds for new code and remove legacy assigneeLike calls during migration","Add unit tests for each query filter combination you support"],"tags":["activiti","task-query","illegal-argument","query-builder"],"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"}