{"record":{"id":"f29035683c1e3cff","repo":"quarkusio/quarkus","slug":"headervalues-must-not-be-null","errorCode":null,"errorMessage":"headerValues must not be null","messagePattern":"headerValues 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":70,"sourceCode":"        return this;\n    }\n\n    @Override\n    public EntityPart.Builder mediaType(String mediaTypeString) throws IllegalArgumentException {\n        if (mediaTypeString == null) {\n            throw new IllegalArgumentException(\"mediaType must not be null\");\n        }\n        this.mediaType = MediaType.valueOf(mediaTypeString);\n        return this;\n    }\n\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","sourceCodeStart":52,"sourceCodeEnd":88,"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#L52-L88","documentation":"EntityPart.Builder.header(String, String...) validates that the varargs headerValues array itself is not null. A null array (distinct from an empty one or a null element) throws IllegalArgumentException immediately.","triggerScenarios":"Calling partBuilder.header(\"X-Custom\", (String[]) null) or passing a null String[] variable as values.","commonSituations":"Forwarding a nullable values array from another method's return; calling header via reflection or with a cast null varargs.","solutions":["Pass at least one non-null value, or call header(name) with a single empty string if an empty header is intended.","Coerce null arrays to an empty array or skip the call when values are absent.","Fix the upstream producer of the values array so it returns an empty array instead of null.","Validate the array before invoking header(...)."],"exampleFix":"// before\nbuilder.header(\"X-Token\", values); // values may be null\n\n// after\nif (values != null && values.length > 0) {\n    builder.header(\"X-Token\", values);\n}","handlingStrategy":"validation","validationCode":"if (values != null && values.length > 0) {\n    builder.header(name, values);\n}","typeGuard":"String[] nonEmpty(String[] v) {\n    return v != null ? v : new String[0];\n}","tryCatchPattern":"try {\n    builder.header(name, values);\n} catch (IllegalArgumentException e) {\n    log.warn(\"Skipping header \" + name + \": null values array\");\n}","preventionTips":["Return empty arrays instead of null from value-producing methods.","Check array length before calling varargs header(...).","Avoid casting null to String[] when calling varargs APIs."],"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-14T00:17:10.932Z"}