{"record":{"id":"18b7ca025b58c4fb","repo":"gradle/gradle","slug":"the-key-s-violates-the-manifest-spec","errorCode":null,"errorMessage":"The Key=%s violates the Manifest spec!","messagePattern":"The Key=(.+?) violates the Manifest spec!","errorType":"validation","errorClass":"ManifestException","httpStatus":null,"severity":"error","filePath":"platforms/jvm/platform-jvm/src/main/java/org/gradle/api/java/archives/internal/DefaultAttributes.java","lineNumber":65,"sourceCode":"    }\n\n    @Override\n    public Object get(Object key) {\n        return attributes.get(key);\n    }\n\n    @Override\n    public Object put(String key, Object value) {\n        if (key == null) {\n            throw new ManifestException(\"The key of a manifest attribute must not be null.\");\n        }\n        if (value == null) {\n            throw new ManifestException(String.format(\"The value of a manifest attribute must not be null (Key=%s).\", key));\n        }\n        try {\n            new java.util.jar.Attributes.Name(key);\n        } catch (IllegalArgumentException e) {\n            throw new ManifestException(String.format(\"The Key=%s violates the Manifest spec!\", key));\n        }\n        return attributes.put(key, value);\n    }\n\n    @Override\n    public Object remove(Object key) {\n        return attributes.remove(key);\n    }\n\n    @Override\n    public void putAll(Map<? extends String, ? extends Object> m) {\n        for (Entry<? extends String, ? extends Object> entry : m.entrySet()) {\n            put(entry.getKey(), entry.getValue());\n        }\n    }\n\n    @Override\n    public void clear() {","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/gradle/gradle/blob/534f27719b66953f95cc907aae7f2c1b12f5482d/platforms/jvm/platform-jvm/src/main/java/org/gradle/api/java/archives/internal/DefaultAttributes.java#L47-L83","documentation":"DefaultAttributes.put validates the key by constructing java.util.jar.Attributes.Name(key). The JDK accepts only names that start with a letter, contain solely alphanumerics and '_', '-', '.', '*', and are at most 70 bytes long. Keys breaking these rules raise ManifestException with 'The Key=%s violates the Manifest spec!'.","triggerScenarios":"attributes.put('Bundle Name', 'x') (space), 'My:Key' (colon), a key starting with a digit or symbol, non-ASCII characters, or a machine-generated key longer than 70 bytes.","commonSituations":"Multi-word keys copied from docs that use spaces instead of hyphens; generated keys (package name + suffix) exceeding the 70-byte limit; localized or unicode attribute names.","solutions":["Rewrite the key using only letters, digits, '_', '-', '.', '*' — e.g. 'My-Attribute' instead of 'My Attribute'.","Shorten generated keys to at most 70 bytes.","Start keys with a letter, never a digit or symbol.","Validate keys yourself with new Attributes.Name(key) before passing them to attributes()."],"exampleFix":"// before\nmanifest.attributes(['My Cool Feature': 'enabled'])  // space is illegal\n\n// after\nmanifest.attributes(['My-Cool-Feature': 'enabled'])","handlingStrategy":"validation","validationCode":"boolean isValidHeaderName(String name) {\n    try {\n        new java.util.jar.Attributes.Name(name)\n        return true\n    } catch (IllegalArgumentException ignored) {\n        return false\n    }\n}\ndef safe = attrs.findAll { k, v -> isValidHeaderName(k as String) }\nmanifest.attributes(safe)","typeGuard":null,"tryCatchPattern":"try {\n    new java.util.jar.Attributes.Name(key)\n    manifest.attributes([(key): value])\n} catch (IllegalArgumentException | org.gradle.api.java.archives.ManifestException e) {\n    throw new GradleException(\"Invalid manifest header name '${key}': ${e.message}\", e)\n}","preventionTips":["Use conventional hyphenated header names ('Implementation-Version', 'Built-By') as models for your own keys.","Keep generated keys under 70 bytes and ASCII-only.","Start header names with a letter; never a digit, space, or punctuation."],"tags":["gradle","manifest","jar","header-name","validation"],"backgroundTag":"invalid-manifest-header-name","analyzedSha":"534f27719b66953f95cc907aae7f2c1b12f5482d","analyzedAt":"2026-08-22T08:09:12.375Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}