{"record":{"id":"b0953dd20af554a1","repo":"quarkusio/quarkus","slug":"multipart-field-name-cannot-be-null","errorCode":null,"errorMessage":"Multipart field name cannot be null","messagePattern":"Multipart field name cannot be null","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartFormDataPart.java","lineNumber":35,"sourceCode":"    private final boolean isObject;\n    private final Class<?> type;\n    private final Buffer content;\n    private final Multi<Byte> multiByteContent;\n\n    public QuarkusMultipartFormDataPart(String name, Buffer content, String mediaType, Class<?> type) {\n        this(name, null, content, mediaType, type);\n    }\n\n    public QuarkusMultipartFormDataPart(String name, String filename, Buffer content, String mediaType, Class<?> type) {\n        this.name = name;\n        this.filename = filename;\n        this.content = content;\n        this.mediaType = mediaType;\n        this.type = type;\n        this.multiByteContent = null;\n\n        if (name == null) {\n            throw new NullPointerException(\"Multipart field name cannot be null\");\n        }\n        if (mediaType == null) {\n            throw new NullPointerException(\"Multipart field media type cannot be null\");\n        }\n        if (type == null) {\n            throw new NullPointerException(\"Multipart field media type cannot be null\");\n        }\n        this.isObject = true;\n        this.value = null;\n        this.pathname = null;\n        this.text = false;\n    }\n\n    public QuarkusMultipartFormDataPart(String name, String filename, Multi<Byte> content, String mediaType, boolean text) {\n        if (name == null) {\n            throw new NullPointerException(\"Multipart field name cannot be null\");\n        }\n        if (mediaType == null) {","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartFormDataPart.java#L17-L53","documentation":"This constructor of QuarkusMultipartFormDataPart validates its arguments and throws NullPointerException when the multipart field name is null. The name is required to build the part's Content-Disposition header, so a null name would produce an invalid multipart body. The library fails fast at construction time rather than producing a malformed request.","triggerScenarios":"Calling new QuarkusMultipartFormDataPart(null, objectValue, mediaType, type) — the object-valued constructor — with a null field name, typically when the name comes from an uninitialized variable, a missing annotation attribute, or a reflection-derived value.","commonSituations":"REST Client multipart @Part handling where the field name is computed at runtime and resolves to null; dynamic part building from a map with null keys; refactoring that removed a hardcoded name.","solutions":["Pass a non-null field name when constructing the part","For REST Client interfaces, ensure each @Part method parameter has a name (parameter name retention or explicit @Part(value=...))","Validate the name source before constructing the part"],"exampleFix":"// before\nnew QuarkusMultipartFormDataPart(name, value, mediaType, type); // name == null\n// after\nObjects.requireNonNull(name, \"name\");\nnew QuarkusMultipartFormDataPart(name, value, mediaType, type);","handlingStrategy":"validation","validationCode":"if (name == null) throw new IllegalArgumentException(\"Multipart field name must not be null\");","typeGuard":"boolean hasName(String name) { return name != null && !name.isBlank(); }","tryCatchPattern":"try {\n    return new QuarkusMultipartFormDataPart(name, value, mediaType, type);\n} catch (NullPointerException e) {\n    throw new IllegalArgumentException(\"Multipart part name is required: \" + e.getMessage(), e);\n}","preventionTips":["Use Objects.requireNonNull on inputs before building parts","In REST Client interfaces, give every @Part an explicit name","Avoid null map lookups as field names"],"tags":["nullpointer","multipart","rest-client","validation"],"backgroundTag":"null-required-field","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"}