Activiti/Activiti · error · ActivitiIllegalArgumentException

Candidate group list is null

Error message

Candidate group list is null

What it means

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.

Solutions

  1. Check the list for null before calling and skip the filter (meaning 'any group') when absent.
  2. Default to Collections.emptyList() and branch: only add the candidateGroupIn filter when the list is non-empty.
  3. Fix the upstream source so the group list is initialized (e.g., new ArrayList<>()) rather than null.
  4. Catch ActivitiIllegalArgumentException around query building if null inputs cannot be prevented.

Example fix

// before
TaskQuery q = taskService.createTaskQuery().taskCandidateGroupIn(groups); // groups may be null
// after
if (groups != null && !groups.isEmpty()) {
    q = taskService.createTaskQuery().taskCandidateGroupIn(groups);
} else {
    q = taskService.createTaskQuery();
}
Defensive patterns

Strategy: validation

Validate before calling

if (candidateGroups == null) { throw new IllegalArgumentException("candidateGroups must not be null before calling taskCandidateGroupIn"); }

Type guard

boolean isUsableGroupList(List<String> groups) { return groups != null && !groups.isEmpty(); }

Try / catch

try {
    query.taskCandidateGroupIn(groups);
} catch (ActivitiIllegalArgumentException e) {
    logger.warn("Invalid candidate group list: {}", e.getMessage());
    query = taskService.createTaskQuery(); // proceed without the filter
}

Prevention

When it happens

Trigger: Passing a null List to taskCandidateGroupIn(null), typically when the list comes from a variable, config property, or upstream service that returned null.

Common situations: 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.

Related errors


AI-assisted analysis of Activiti/Activiti@56435b1a97 (2026-09-09). Data as JSON: /api/errors/5a5dc35bd430eecc. Report an issue: GitHub.

Appendix: source

Thrown at activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/TaskQueryImpl.java:598

            );
        }

        if (orActive) {
            currentOrQueryObject.bothCandidateAndAssigned = true;
            currentOrQueryObject.userIdForCandidateAndAssignee = userIdForCandidateAndAssignee;
            currentOrQueryObject.candidateGroups = usersGroups;
        } else {
            this.bothCandidateAndAssigned = true;
            this.userIdForCandidateAndAssignee = userIdForCandidateAndAssignee;
            this.candidateGroups = usersGroups;
        }

        return this;
    }

    public TaskQuery taskCandidateGroupIn(List<String> candidateGroups) {
        if (candidateGroups == null) {
            throw new ActivitiIllegalArgumentException("Candidate group list is null");
        }

        if (candidateGroups.isEmpty()) {
            throw new ActivitiIllegalArgumentException("Candidate group list is empty");
        }

        if (candidateGroup != null) {
            throw new ActivitiIllegalArgumentException(
                "Invalid query usage: cannot set both candidateGroupIn and candidateGroup"
            );
        }

        if (orActive) {
            currentOrQueryObject.candidateGroups = candidateGroups;
        } else {
            this.candidateGroups = candidateGroups;
        }
        return this;

View on GitHub (pinned to 56435b1a97)