{"record":{"id":"7b2107a940b40923","repo":"gradle/gradle","slug":"cannot-add-an-extra-info-element-with-null-namespa","errorCode":null,"errorMessage":"Cannot add an extra info element with null namespace","messagePattern":"Cannot add an extra info element with null namespace","errorType":"validation","errorClass":"InvalidUserDataException","httpStatus":null,"severity":"error","filePath":"platforms/software/ivy/src/main/java/org/gradle/api/publish/ivy/internal/publication/DefaultIvyModuleDescriptorSpec.java","lineNumber":93,"sourceCode":"    }\n\n    @Override\n    public void setBranch(@Nullable String branch) {\n        this.branch = branch;\n    }\n\n    @Override\n    public IvyExtraInfoSpec getExtraInfo() {\n        return extraInfo;\n    }\n\n    @Override\n    public void extraInfo(String namespace, String elementName, String value) {\n        if (elementName == null) {\n            throw new InvalidUserDataException(\"Cannot add an extra info element with null element name\");\n        }\n        if (namespace == null) {\n            throw new InvalidUserDataException(\"Cannot add an extra info element with null namespace\");\n        }\n        extraInfo.add(namespace, elementName, value);\n    }\n\n    @Override\n    public IvyPublicationCoordinates getCoordinates() {\n        return ivyPublicationCoordinates;\n    }\n\n    @Override\n    public void withXml(Action<? super XmlProvider> action) {\n        xmlActions.add(new UserCodeAction<>(\"Could not apply withXml() to Ivy module descriptor\", action));\n    }\n\n    @Override\n    public Action<XmlProvider> getXmlAction() {\n        return xmlActions;\n    }","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/gradle/gradle/blob/534f27719b66953f95cc907aae7f2c1b12f5482d/platforms/software/ivy/src/main/java/org/gradle/api/publish/ivy/internal/publication/DefaultIvyModuleDescriptorSpec.java#L75-L111","documentation":"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.","triggerScenarios":"ivyModuleDescriptor.extraInfo(null, 'myElement', 'value') — often the namespace variable is missing, or code assumes the namespace can be omitted by passing null.","commonSituations":"Optional-namespace metadata code that passes null to mean 'none'; map-driven extra-info generation where the namespace key is absent.","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"],"exampleFix":"// before:\nivyModuleDescriptor.extraInfo(null, 'myElement', 'value')\n// after:\nivyModuleDescriptor.extraInfo('', 'myElement', 'value') // default Ivy namespace","handlingStrategy":"validation","validationCode":"def ns = namespace ?: '' // empty string = default Ivy namespace; null is rejected\nif (namespace == null) {\n    logger.warn('extraInfo namespace missing for element <{}>; using default namespace', elementName)\n}\nivyModuleDescriptor.extraInfo(ns, elementName, value)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use '' (empty string) for the default namespace instead of null","Default optional namespaces before building extra-info entries"],"tags":["gradle","ivy","publishing","null-check","validation"],"backgroundTag":"null-argument","analyzedSha":"534f27719b66953f95cc907aae7f2c1b12f5482d","analyzedAt":"2026-08-22T08:09:12.375Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}