gradle/gradle · error · InvalidUserDataException
Cannot add an extra info element with null namespace
Error message
Cannot add an extra info element with null namespace
What it means
The sibling null guard in DefaultIvyModuleDescriptorSpec.extraInfo: the namespace argument must not be null, otherwise InvalidUserDataException is thrown. Ivy extra-info elements are keyed by (namespace, name); an empty-string namespace is acceptable (the default Ivy namespace), but null is not.
Source
Thrown at platforms/software/ivy/src/main/java/org/gradle/api/publish/ivy/internal/publication/DefaultIvyModuleDescriptorSpec.java:93
}
@Override
public void setBranch(@Nullable String branch) {
this.branch = branch;
}
@Override
public IvyExtraInfoSpec getExtraInfo() {
return extraInfo;
}
@Override
public void extraInfo(String namespace, String elementName, String value) {
if (elementName == null) {
throw new InvalidUserDataException("Cannot add an extra info element with null element name");
}
if (namespace == null) {
throw new InvalidUserDataException("Cannot add an extra info element with null namespace");
}
extraInfo.add(namespace, elementName, value);
}
@Override
public IvyPublicationCoordinates getCoordinates() {
return ivyPublicationCoordinates;
}
@Override
public void withXml(Action<? super XmlProvider> action) {
xmlActions.add(new UserCodeAction<>("Could not apply withXml() to Ivy module descriptor", action));
}
@Override
public Action<XmlProvider> getXmlAction() {
return xmlActions;
}View on GitHub (pinned to 534f27719b)
Solutions
- Pass an empty string '' for the default namespace instead of null
- Default the namespace (e.g. to the Ivy or a project namespace) before calling extraInfo
- Validate both namespace and name for null when generating entries dynamically
Example fix
// before:
ivyModuleDescriptor.extraInfo(null, 'myElement', 'value')
// after:
ivyModuleDescriptor.extraInfo('', 'myElement', 'value') // default Ivy namespace Defensive patterns
Strategy: validation
Validate before calling
def ns = namespace ?: '' // empty string = default Ivy namespace; null is rejected
if (namespace == null) {
logger.warn('extraInfo namespace missing for element <{}>; using default namespace', elementName)
}
ivyModuleDescriptor.extraInfo(ns, elementName, value) Prevention
- Use '' (empty string) for the default namespace instead of null
- Default optional namespaces before building extra-info entries
When it happens
Trigger: ivyModuleDescriptor.extraInfo(null, 'myElement', 'value') — often the namespace variable is missing, or code assumes the namespace can be omitted by passing null.
Common situations: Optional-namespace metadata code that passes null to mean 'none'; map-driven extra-info generation where the namespace key is absent.
Related errors
- Cannot add an extra info element with null element name
- Invalid ivy extra info element name: '%s'
- Ivy publication '%s' cannot include multiple components
- Illegal null value provided in this collection: %s
- Configuring the dependency resolve details with 'null' versi
AI-assisted analysis of gradle/gradle@534f27719b (2026-08-22).
Data as JSON: /api/errors/7b2107a940b40923.
Report an issue: GitHub.