{"record":{"id":"197a86cfacb0b12e","repo":"quarkusio/quarkus","slug":"multipart-field-value-cannot-be-null","errorCode":null,"errorMessage":"Multipart field value cannot be null","messagePattern":"Multipart field value 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":75,"sourceCode":"        this.name = name;\n        this.multiByteContent = content;\n        this.mediaType = mediaType;\n        this.filename = filename;\n        this.text = text;\n\n        this.isObject = false;\n        this.value = null;\n        this.pathname = null;\n        this.type = null;\n        this.content = null;\n    }\n\n    public QuarkusMultipartFormDataPart(String name, String value, String filename) {\n        if (name == null) {\n            throw new NullPointerException(\"Multipart field name cannot be null\");\n        }\n        if (value == null) {\n            throw new NullPointerException(\"Multipart field value cannot be null\");\n        }\n        this.name = name;\n        this.value = value;\n        this.filename = filename;\n        this.pathname = null;\n        this.content = null;\n        this.multiByteContent = null;\n        this.mediaType = null;\n        this.text = false;\n        this.isObject = false;\n        this.type = null;\n    }\n\n    public QuarkusMultipartFormDataPart(String name, String filename, String pathname, String mediaType, boolean text) {\n        if (name == null) {\n            throw new NullPointerException(\"Multipart field name cannot be null\");\n        }\n        if (filename == null) {","sourceCodeStart":57,"sourceCodeEnd":93,"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#L57-L93","documentation":"The simple String-value constructor requires a non-null value and throws NullPointerException when the field value is null. A text part with a null value cannot be encoded into the multipart body, so the library rejects it during construction.","triggerScenarios":"Calling new QuarkusMultipartFormDataPart(name, null, filename) — a null string value, typically when the value is fetched from a map/config lookup that misses, or from a DTO getter returning null.","commonSituations":"Sending optional fields where the caller passes null instead of omitting the part or an empty string; lookups on maps with absent keys.","solutions":["Skip adding the part when the value is null (conditional add)","Pass an empty string if the field must be present but has no value","Coalesce with a default before construction"],"exampleFix":"// before\nparts.add(new QuarkusMultipartFormDataPart(\"note\", note, null)); // note == null\n// after\nif (note != null) {\n    parts.add(new QuarkusMultipartFormDataPart(\"note\", note, null));\n}","handlingStrategy":"validation","validationCode":"if (value == null) throw new IllegalArgumentException(\"Multipart field value must not be null (omit the part or use \\\"\\\")\");","typeGuard":null,"tryCatchPattern":"try {\n    return new QuarkusMultipartFormDataPart(name, value, filename);\n} catch (NullPointerException e) {\n    throw new IllegalArgumentException(\"Field value is required; skip the part if optional\", e);\n}","preventionTips":["Conditionally add parts only when the value is present","Use Map.getOrDefault/Optional to supply defaults","Decide explicitly between omitting the field and sending an empty string"],"tags":["nullpointer","multipart","rest-client"],"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-12T22:17:10.623Z"}