quarkusio/quarkus · error · java.lang.IllegalArgumentException
type must not be empty
Error message
type must not be empty
What it means
Guard in the private Purl constructor: the type component of the package URL was non-null but empty (e.g. 'pkg:/name' with the type omitted). The type segment is mandatory in a purl, so construction fails.
Source
Thrown at independent-projects/bootstrap/app-model/src/main/java/io/quarkus/sbom/Purl.java:201
subpath = null;
}
return new Purl(type, namespace, name, version, qualifiers, subpath);
}
private final String type;
private final String namespace;
private final String name;
private final String version;
private final Map<String, String> qualifiers;
private final String subpath;
private volatile String canonical;
private Purl(String type, String namespace, String name, String version,
Map<String, String> qualifiers, String subpath) {
Objects.requireNonNull(type, "type is required");
if (type.isEmpty()) {
throw new IllegalArgumentException("type must not be empty");
}
validateType(type);
this.type = type.toLowerCase(Locale.ROOT);
this.namespace = namespace == null || namespace.isEmpty() ? null : namespace;
Objects.requireNonNull(name, "name is required");
if (name.isEmpty()) {
throw new IllegalArgumentException("name must not be empty");
}
if (TYPE_MAVEN.equals(this.type) && this.namespace == null) {
throw new IllegalArgumentException("Maven PURL is missing a namespace (groupId) for name (artifactId) " + name);
}
this.name = TYPE_NPM.equals(this.type) ? name.toLowerCase(Locale.ROOT) : name;
this.version = version;
this.qualifiers = qualifiers == null || qualifiers.isEmpty()
? Map.of()
: qualifiers;
this.subpath = normalizeSubpath(subpath);
}View on GitHub (pinned to e1c734241f)
Solutions
- Supply a valid type like 'maven', 'npm', 'gem' before constructing
- Check the source of the type value (config/variable) for empty strings
- Use Purl.parse() on a complete purl string instead of assembling components
Example fix
// before
Purl p = Purl.of(type, namespace, name); // type == ""
// after
if (type == null || type.isEmpty()) { throw new IllegalStateException("artifact type missing"); }
Purl p = Purl.of(type, namespace, name); Defensive patterns
Strategy: validation
Validate before calling
if (type == null || type.isEmpty()) { throw new IllegalArgumentException("purl type required"); } Type guard
boolean hasValidType(String t) { return t != null && !t.isEmpty() && t.matches("[a-zA-Z0-9._-]+"); } Try / catch
try { Purl p = Purl.of(type, ns, name); } catch (IllegalArgumentException e) { if (e.getMessage().contains("type must not be empty")) { type = inferType(artifact); p = Purl.of(type, ns, name); } else { throw e; } } Prevention
- Default the type to 'maven' for Maven builds
- Validate config-driven type values before use
- Prefer Purl.ofMaven/parse over manual component assembly
When it happens
Trigger: Programmatic Purl construction via factory methods (e.g. Purl.ofMaven(...) / builder) passing an empty type; parse() normally guarantees this, so direct construction with empty type is the trigger.
Common situations: Building purls dynamically where the type variable is uninitialized or stripped (e.g. empty config value for artifact type).
Related errors
- Invalid PURL:
- Invalid PURL qualifier
- name must not be empty
- Maven PURL is missing a namespace (groupId) for name (artifa
- PURL type must start with a letter:
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/768a36d652395353.
Report an issue: GitHub.