quarkusio/quarkus · error · IllegalStateException

ArtifactCoordsSegmentPattern.of() expects groupId:artifactId

Error message

ArtifactCoordsSegmentPattern.of() expects groupId:artifactId:version or groupId:artifactId:classifier:type:version; found: ${wildcardPattern}

What it means

ArtifactCoordsPattern.of accepts only 3-segment (groupId:artifactId:version) or 5-segment (groupId:artifactId:classifier:type:version) patterns. When a pattern has 4 segments and the 4th segment is followed by nothing usable (parts.length <= 4 after the classifier branch), it throws IllegalStateException explaining the accepted formats.

Source

Thrown at independent-projects/bootstrap/app-model/src/main/java/io/quarkus/maven/dependency/ArtifactCoordsPattern.java:282

        var artifactIdPattern = ArtifactCoordsSegmentPattern.MATCH_ALL;
        var typePattern = ArtifactCoordsSegmentPattern.MATCH_ALL;
        var classifierPattern = ArtifactCoordsSegmentPattern.MATCH_ALL;
        var versionPattern = ArtifactCoordsSegmentPattern.MATCH_ALL;
        var parts = wildcardPattern.split(DELIMITER_STRING);
        if (parts.length > 0) {
            groupIdPattern = new ArtifactCoordsSegmentPattern(parts[0]);
            if (parts.length > 1) {
                artifactIdPattern = new ArtifactCoordsSegmentPattern(parts[1]);
                if (parts.length > 2) {
                    final String third = parts[2];
                    if (parts.length > 3) {
                        final String fourth = parts[3];
                        if (parts.length > 4) {
                            classifierPattern = new ArtifactCoordsSegmentPattern(third);
                            typePattern = new ArtifactCoordsSegmentPattern(fourth);
                            versionPattern = new ArtifactCoordsSegmentPattern(parts[4]);
                        } else {
                            throw new IllegalStateException(
                                    ArtifactCoordsSegmentPattern.class.getName()
                                            + ".of() expects groupId:artifactId:version or groupId:artifactId:classifier:type:version; found: "
                                            + wildcardPattern);
                        }
                    } else {
                        versionPattern = new ArtifactCoordsSegmentPattern(third);
                    }
                }
            }
        }
        return new ArtifactCoordsPattern(groupIdPattern, artifactIdPattern, classifierPattern, typePattern, versionPattern);
    }

    final ArtifactCoordsSegmentPattern groupIdPattern;
    final ArtifactCoordsSegmentPattern artifactIdPattern;
    final ArtifactCoordsSegmentPattern classifierPattern;
    final ArtifactCoordsSegmentPattern typePattern;
    final ArtifactCoordsSegmentPattern versionPattern;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Use exactly 3 segments (groupId:artifactId:version) or 5 segments (groupId:artifactId:classifier:type:version), using '*' wildcards as needed
  2. Convert 4-segment patterns to 5-segment by inserting an explicit classifier or type segment (e.g. G:A:*:jar:*)
  3. Pre-validate the segment count (2 or 4 ':' separators) before calling of()

Example fix

// before
ArtifactCoordsPattern p = ArtifactCoordsPattern.of("com.acme:app:*:*"); // throws
// after
ArtifactCoordsPattern p = ArtifactCoordsPattern.of("com.acme:app:*:*:*");
Defensive patterns

Strategy: validation

Validate before calling

boolean isValidPattern(String p) {
    int segs = p.split(":", -1).length;
    return segs == 3 || segs == 5;
}

Try / catch

try {
    ArtifactCoordsPattern.of(pattern);
} catch (IllegalStateException e) {
    if (e.getMessage().contains("expects groupId:artifactId:version")) {
        throw new IllegalArgumentException("Use 3 or 5 colon-separated segments: " + pattern);
    }
}

Prevention

When it happens

Trigger: Calling ArtifactCoordsPattern.of/wildcardOf with a 4-segment pattern such as "com.acme:app:*:*" or "group:*:1.0:jar" — a shape that is neither 3 nor 5 segments.

Common situations: Writing dependency include/exclude patterns in Quarkus config where users habitually write 4-segment Maven coords (G:A:C:V) or (G:A:type:V); migrating regex patterns between tools with different accepted segment counts.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/1b30bc109f901911. Report an issue: GitHub.