{"record":{"id":"df3a7c21d223dee2","repo":"flowable/flowable-engine","slug":"candidate-group-list-is-empty","errorCode":null,"errorMessage":"Candidate group list is empty","messagePattern":"Candidate group list is empty","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/HistoricTaskInstanceQueryImpl.java","lineNumber":1926,"sourceCode":"            throw new FlowableIllegalArgumentException(\"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(Collection<String> candidateGroups) {\n        if (candidateGroups == null) {\n            throw new FlowableIllegalArgumentException(\"Candidate group list is null\");\n        }\n\n        if (candidateGroups.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"Candidate group list is empty\");\n        }\n\n        if (candidateGroup != null) {\n            throw new FlowableIllegalArgumentException(\"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 (involvedUser == null) {\n            throw new FlowableIllegalArgumentException(\"involved user is null\");","sourceCodeStart":1908,"sourceCodeEnd":1944,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/HistoricTaskInstanceQueryImpl.java#L1908-L1944","documentation":"taskCandidateGroupIn(Collection<String>) throws this error when the collection argument is non-null but has no elements. An empty IN-list would generate invalid or meaningless SQL, so Flowable rejects it eagerly.","triggerScenarios":"Calling taskCandidateGroupIn(new ArrayList<>()) or taskCandidateGroupIn(Collections.emptyList()) — typically after filtering a group list down to zero elements, or when the user belongs to no groups.","commonSituations":"Filtering groups by permission/type and passing the (possibly empty) result; users with no group memberships; split of a blank comma-separated group string yielding an empty list.","solutions":["Guard with !candidateGroups.isEmpty() before calling and skip the filter when empty.","If 'no groups' should match nothing, return an empty result yourself without executing the query.","If 'no groups' should match everything, build the query without any candidate-group criterion."],"exampleFix":"// before\nquery.taskCandidateGroupIn(myGroups); // throws when myGroups is empty\n\n// after\nif (myGroups != null && !myGroups.isEmpty()) {\n    query.taskCandidateGroupIn(myGroups);\n}","handlingStrategy":"validation","validationCode":"if (candidateGroups != null && !candidateGroups.isEmpty()) {\n    historicTaskInstanceQuery.taskCandidateGroupIn(candidateGroups);\n} else {\n    // decide: either return an empty result or build the query without this filter\n}","typeGuard":"boolean hasGroups(Collection<String> groups) {\n    return groups != null && !groups.isEmpty();\n}","tryCatchPattern":"try {\n    query.taskCandidateGroupIn(candidateGroups);\n} catch (FlowableIllegalArgumentException e) {\n    // empty list: decide semantics — short-circuit to empty result or drop the filter\n    return Collections.emptyList();\n}","preventionTips":["Check isEmpty() before any taskCandidateGroupIn() call.","Decide explicitly what 'user has no groups' means (no results vs unfiltered).","Filter lists before querying and skip the criterion if filtering emptied them."],"tags":["flowable","query-validation","empty-collection","task-query"],"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"}