{"record":{"id":"5a5dc35bd430eecc","repo":"Activiti/Activiti","slug":"candidate-group-list-is-null-5a5dc3","errorCode":null,"errorMessage":"Candidate group list is null","messagePattern":"Candidate group list is null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/TaskQueryImpl.java","lineNumber":598,"sourceCode":"            );\n        }\n\n        if (orActive) {\n            currentOrQueryObject.bothCandidateAndAssigned = true;\n            currentOrQueryObject.userIdForCandidateAndAssignee = userIdForCandidateAndAssignee;\n            currentOrQueryObject.candidateGroups = usersGroups;\n        } else {\n            this.bothCandidateAndAssigned = true;\n            this.userIdForCandidateAndAssignee = userIdForCandidateAndAssignee;\n            this.candidateGroups = usersGroups;\n        }\n\n        return this;\n    }\n\n    public TaskQuery 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(\n                \"Invalid query usage: cannot set both candidateGroupIn and candidateGroup\"\n            );\n        }\n\n        if (orActive) {\n            currentOrQueryObject.candidateGroups = candidateGroups;\n        } else {\n            this.candidateGroups = candidateGroups;\n        }\n        return this;","sourceCodeStart":580,"sourceCodeEnd":616,"githubUrl":"https://github.com/Activiti/Activiti/blob/56435b1a97deeafdc09dd40074b056c89fba5a8a/activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/TaskQueryImpl.java#L580-L616","documentation":"taskCandidateGroupIn(List<String>) requires a non-null list because it builds an IN clause over identity-link groups; a null list has no meaningful query translation. Activiti validates the argument eagerly and throws ActivitiIllegalArgumentException.","triggerScenarios":"Passing a null List to taskCandidateGroupIn(null), typically when the list comes from a variable, config property, or upstream service that returned null.","commonSituations":"A group list fetched from a database/config that is null instead of empty; a method parameter passed straight through to the query; deserialization of an optional groups field yielding null.","solutions":["Check the list for null before calling and skip the filter (meaning 'any group') when absent.","Default to Collections.emptyList() and branch: only add the candidateGroupIn filter when the list is non-empty.","Fix the upstream source so the group list is initialized (e.g., new ArrayList<>()) rather than null.","Catch ActivitiIllegalArgumentException around query building if null inputs cannot be prevented."],"exampleFix":"// before\nTaskQuery q = taskService.createTaskQuery().taskCandidateGroupIn(groups); // groups may be null\n// after\nif (groups != null && !groups.isEmpty()) {\n    q = taskService.createTaskQuery().taskCandidateGroupIn(groups);\n} else {\n    q = taskService.createTaskQuery();\n}","handlingStrategy":"validation","validationCode":"if (candidateGroups == null) { throw new IllegalArgumentException(\"candidateGroups must not be null before calling taskCandidateGroupIn\"); }","typeGuard":"boolean isUsableGroupList(List<String> groups) { return groups != null && !groups.isEmpty(); }","tryCatchPattern":"try {\n    query.taskCandidateGroupIn(groups);\n} catch (ActivitiIllegalArgumentException e) {\n    logger.warn(\"Invalid candidate group list: {}\", e.getMessage());\n    query = taskService.createTaskQuery(); // proceed without the filter\n}","preventionTips":["Initialize group lists with Collections.emptyList() instead of null","Null-check values coming from config or upstream services before query building","Only add the candidateGroupIn filter when the list is usable"],"tags":["activiti","task-query","null-argument","validation"],"backgroundTag":"null-argument","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"}