gradle/gradle · error · IllegalArgumentException

Problem id parent must not be null

Error message

Problem id parent must not be null

What it means

DefaultProblemId's constructor requires a non-null parent ProblemGroup; every problem ID belongs to a group (the group provides context and grouping in reports). A null parent leaves the ID unattached, so validateFields throws IllegalArgumentException('Problem id parent must not be null').

Source

Thrown at platforms/ide/problems-api/src/main/java/org/gradle/api/problems/internal/DefaultProblemId.java:48

    private final String displayName;
    private final ProblemGroup parent;

    public DefaultProblemId(String name, String displayName, ProblemGroup parent) {
        validateFields(name, displayName, parent);
        this.name = TextUtil.replaceLineSeparatorsOf(name, "");
        this.displayName = TextUtil.replaceLineSeparatorsOf(displayName, "");
        this.parent = parent;
    }

    private static void validateFields(String name, String displayName, ProblemGroup parent) {
        if (TextUtil.isBlank(name)) {
            throw new IllegalArgumentException("Problem id name must not be blank");
        }
        if (TextUtil.isBlank(displayName)) {
            throw new IllegalArgumentException("Problem id displayName must not be blank");
        }
        if (parent == null) {
            throw new IllegalArgumentException("Problem id parent must not be null");
        }
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public String getDisplayName() {
        return displayName;
    }

    @Override
    public ProblemGroup getGroup() {
        return parent;
    }

View on GitHub (pinned to 534f27719b)

Solutions

  1. Pass an existing ProblemGroup, e.g. new DefaultProblemId('name', 'display', new DefaultProblemGroup('group', 'Group display'))
  2. If the group is looked up, fail with a clear message when the lookup returns null instead of passing null through
  3. Use the public problems API where groups are created and attached for you

Example fix

// before
ProblemId id = new DefaultProblemId("parse-error", "Parse error", findGroup(groupId)); // returns null -> throws

// after
ProblemGroup group = findGroup(groupId);
if (group == null) throw new IllegalArgumentException("Unknown problem group: " + groupId);
ProblemId id = new DefaultProblemId("parse-error", "Parse error", group);
Defensive patterns

Strategy: validation

Validate before calling

// Java: null-check the parent before constructing
ProblemGroup group = findGroup(groupId);
if (group == null) {
    throw new IllegalArgumentException("Unknown problem group id: " + groupId);
}
ProblemId id = new DefaultProblemId("name", "display", group);

Prevention

When it happens

Trigger: Constructing new DefaultProblemId("name", "displayName", null); passing a group variable that was never assigned; a factory method that forgets the group argument.

Common situations: Copy-pasted ID construction with the group parameter dropped; group lookup (e.g. from a registry) returning null for an unknown key; older code migrated from APIs where parent was optional.

Related errors


AI-assisted analysis of gradle/gradle@534f27719b (2026-08-22). Data as JSON: /api/errors/e6ac4351afd9799e. Report an issue: GitHub.