{"record":{"id":"0512d90e7b5b1ea5","repo":"flowable/flowable-engine","slug":"candidate-group-list-is-empty-0512d9","errorCode":null,"errorMessage":"Candidate group list is empty","messagePattern":"Candidate group list is empty","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/TaskQueryImpl.java","lineNumber":664,"sourceCode":"        if (orActive) {\n            currentOrQueryObject.bothCandidateAndAssigned = true;\n            currentOrQueryObject.userIdForCandidateAndAssignee = userIdForCandidateAndAssignee;\n        } else {\n            this.bothCandidateAndAssigned = true;\n            this.userIdForCandidateAndAssignee = userIdForCandidateAndAssignee;\n        }\n\n        return this;\n    }\n\n    @Override\n    public TaskQuery 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 (orActive) {\n            currentOrQueryObject.candidateGroups = candidateGroups;\n        } else {\n            this.candidateGroups = candidateGroups;\n        }\n        return this;\n    }\n\n    @Override\n    public TaskQuery ignoreAssigneeValue() {\n        if (orActive) {\n            currentOrQueryObject.ignoreAssigneeValue = true;","sourceCodeStart":646,"sourceCodeEnd":682,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/TaskQueryImpl.java#L646-L682","documentation":"TaskQueryImpl.taskCandidateGroupIn() throws this when the collection is non-null but empty. An empty IN list is meaningless or invalid SQL, so Flowable rejects it explicitly. Treat 'no filter' as not calling the setter, not as an empty list.","triggerScenarios":"Calling taskQuery.taskCandidateGroupIn(new ArrayList<>()) or a list reduced to zero elements by prior filtering/authorization logic.","commonSituations":"User belongs to no groups so the resolved group list is empty; authorization filter stripped all groups; default empty list passed unconditionally in generic query-builder code.","solutions":["Call taskCandidateGroupIn() only when the collection has at least one element.","On empty, either skip the filter or short-circuit to an empty result set if that matches your authorization model.","Fix group resolution so expected groups are actually populated.","Do not use empty collections to mean 'match nothing'; handle that case in caller logic."],"exampleFix":"// before\nTaskQuery query = taskService.createTaskQuery().taskCandidateGroupIn(groups);\n// after\nif (groups == null || groups.isEmpty()) {\n    return Collections.emptyList();\n}\nTaskQuery query = taskService.createTaskQuery().taskCandidateGroupIn(groups);","handlingStrategy":"validation","validationCode":"if (candidateGroups == null || candidateGroups.isEmpty()) {\n    throw new IllegalArgumentException(\"candidateGroups must contain at least one group\");\n}\nquery.taskCandidateGroupIn(candidateGroups);","typeGuard":"boolean isNonEmptyCandidateGroups(Collection<String> g) { return g != null && !g.isEmpty(); }","tryCatchPattern":"try {\n    query.taskCandidateGroupIn(groups);\n} catch (FlowableIllegalArgumentException e) {\n    logger.warn(\"Empty candidate group list: {}\", e.getMessage());\n    return Collections.emptyList(); // no groups -> no candidate tasks\n}","preventionTips":["Handle the no-groups authorization case explicitly before querying","Never pass empty collections to IN-style filters","Validate collections after filtering (e.g. by tenant or authorization)","Add tests for empty group-list scenarios"],"tags":["flowable","task-query","empty-collection","candidate-group"],"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"}