{"record":{"id":"b17c2027b9b40fac","repo":"quarkusio/quarkus","slug":"newheaders-must-not-be-null","errorCode":null,"errorMessage":"newHeaders must not be null","messagePattern":"newHeaders must not be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/EntityPartBuilderImpl.java","lineNumber":81,"sourceCode":"\n    @Override\n    public EntityPart.Builder header(String headerName, String... headerValues) throws IllegalArgumentException {\n        if (headerName == null) {\n            throw new IllegalArgumentException(\"headerName must not be null\");\n        }\n        if (headerValues == null) {\n            throw new IllegalArgumentException(\"headerValues must not be null\");\n        }\n        for (String value : headerValues) {\n            headers.add(headerName, value);\n        }\n        return this;\n    }\n\n    @Override\n    public EntityPart.Builder headers(MultivaluedMap<String, String> newHeaders) throws IllegalArgumentException {\n        if (newHeaders == null) {\n            throw new IllegalArgumentException(\"newHeaders must not be null\");\n        }\n        this.headers = new QuarkusMultivaluedHashMap<>();\n        this.headers.putAll(newHeaders);\n        return this;\n    }\n\n    @Override\n    public EntityPart.Builder fileName(String fileName) throws IllegalArgumentException {\n        this.fileName = fileName;\n        return this;\n    }\n\n    @Override\n    public EntityPart.Builder content(InputStream content) throws IllegalArgumentException {\n        if (content == null) {\n            throw new IllegalArgumentException(\"content must not be null\");\n        }\n        this.content = content;","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/EntityPartBuilderImpl.java#L63-L99","documentation":"EntityPart.Builder.headers(MultivaluedMap) replaces the part's entire header map; a null map cannot be copied and throws IllegalArgumentException. The builder defensively clears and re-populates from the provided map.","triggerScenarios":"Calling partBuilder.headers(null), typically when the replacement map comes from a method or lookup that returned null.","commonSituations":"Copying headers from a response/request object where the map getter returned null; optional header sets that are absent by design.","solutions":["Pass an actual MultivaluedMap; use a new empty QuarkusMultivaluedHashMap/MultivaluedHashMap when there are no headers.","Skip the headers(...) call entirely when the source map is null.","Fix the getter producing the map to return an empty map instead of null.","Guard the call with a null check before replacing headers."],"exampleFix":"// before\nbuilder.headers(existingHeaders); // may be null\n\n// after\nif (existingHeaders != null) {\n    builder.headers(existingHeaders);\n}","handlingStrategy":"validation","validationCode":"if (newHeaders != null) {\n    builder.headers(newHeaders);\n}","typeGuard":"MultivaluedMap<String, String> orEmpty(MultivaluedMap<String, String> m) {\n    return m != null ? m : new MultivaluedHashMap<>();\n}","tryCatchPattern":"try {\n    builder.headers(newHeaders);\n} catch (IllegalArgumentException e) {\n    builder.headers(new MultivaluedHashMap<>());\n}","preventionTips":["Ensure map getters return empty maps, never null.","Skip the headers(...) call when the source map is absent.","Centralize part-building in one helper that normalizes null maps."],"tags":["resteasy-reactive","jax-rs","multipart","entitypart","headers","null-argument"],"backgroundTag":"null-required-argument","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}