{"record":{"id":"d213746145929e0e","repo":"flowable/flowable-engine","slug":"candidate-group-list-is-empty-d21374","errorCode":null,"errorMessage":"Candidate group list is empty","messagePattern":"Candidate group list is empty","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/HistoricTaskInstanceQueryImpl.java","lineNumber":1103,"sourceCode":"            throw new ActivitiIllegalArgumentException(\"Invalid query usage: cannot set both candidateGroup and candidateGroupIn\");\n        }\n\n        if (inOrStatement) {\n            this.currentOrQueryObject.candidateGroup = candidateGroup;\n        } else {\n            this.candidateGroup = candidateGroup;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricTaskInstanceQuery taskCandidateGroupIn(List<String> candidateGroups) {\n        if (candidateGroups == null) {\n            throw new ActivitiIllegalArgumentException(\"Candidate group list is null\");\n        }\n\n        if (candidateGroups.isEmpty()) {\n            throw new ActivitiIllegalArgumentException(\"Candidate group list is empty\");\n        }\n\n        if (candidateGroup != null) {\n            throw new ActivitiIllegalArgumentException(\"Invalid query usage: cannot set both candidateGroupIn and candidateGroup\");\n        }\n\n        if (inOrStatement) {\n            this.currentOrQueryObject.candidateGroups = candidateGroups;\n        } else {\n            this.candidateGroups = candidateGroups;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoricTaskInstanceQuery taskInvolvedUser(String involvedUser) {\n        if (inOrStatement) {\n            this.currentOrQueryObject.involvedUser = involvedUser;","sourceCodeStart":1085,"sourceCodeEnd":1121,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/HistoricTaskInstanceQueryImpl.java#L1085-L1121","documentation":"taskCandidateGroupIn(List<String>) rejects an empty list: an IN filter with zero values has no meaning, so the engine throws ActivitiIllegalArgumentException instead of producing a query that matches nothing or everything ambiguously.","triggerScenarios":"Calling taskCandidateGroupIn(Collections.emptyList()) or any list of size 0 on a HistoricTaskInstanceQuery (also inside an or() block).","commonSituations":"Multi-select UI where no group was chosen but the query is still built; group filter derived from a permission set that is empty for the current user; JDBC/IN-clause habits carried over where empty lists were filtered out downstream.","solutions":["Check !candidateGroups.isEmpty() and skip the filter call when empty (result: no candidate-group filter).","If an empty selection should return no results by design, short-circuit and skip executing the query instead.","Ensure upstream group resolvers return null/absent rather than an empty list when no filter is intended, and guard accordingly."],"exampleFix":"// before\nList<String> groups = userPermissions.getGroups(); // may be empty\nquery.taskCandidateGroupIn(groups); // throws when empty\n\n// after\nList<String> groups = userPermissions.getGroups();\nif (groups != null && !groups.isEmpty()) {\n    query.taskCandidateGroupIn(groups);\n}","handlingStrategy":"validation","validationCode":"// Java\nif (candidateGroups != null && !candidateGroups.isEmpty()) {\n    query.taskCandidateGroupIn(candidateGroups);\n} // else: no group filter (or short-circuit for zero results by design)","typeGuard":null,"tryCatchPattern":"try {\n    query.taskCandidateGroupIn(groups);\n} catch (org.activiti.engine.ActivitiIllegalArgumentException e) {\n    // decide: skip filter, or return empty result set intentionally\n}","preventionTips":["Check list size before every *In(...) query filter call.","Decide explicitly whether an empty selection means 'no filter' or 'no results'.","Test query builders with empty collections."],"tags":["query-builder","empty-collection","flowable","activiti"],"backgroundTag":"empty-required-field","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"}