{"record":{"id":"a7fcfafd333dd2cf","repo":"quarkusio/quarkus","slug":"multipart-field-name-content-cannot-be-null-when-s","errorCode":null,"errorMessage":"Multipart field name content cannot be null when sending files","messagePattern":"Multipart field name content cannot be null when sending files","errorType":"validation","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":122,"sourceCode":"        this.filename = filename;\n        this.pathname = pathname;\n        this.content = null;\n        this.multiByteContent = null;\n        this.mediaType = mediaType;\n        this.text = text;\n        this.isObject = false;\n        this.type = null;\n    }\n\n    public QuarkusMultipartFormDataPart(String name, String filename, Buffer content, String mediaType, boolean text) {\n        if (name == null) {\n            throw new NullPointerException(\"Multipart field name cannot be null\");\n        }\n        if (filename == null) {\n            throw new NullPointerException(\"Multipart field name filename cannot be null when sending files\");\n        }\n        if (content == null) {\n            throw new NullPointerException(\"Multipart field name content cannot be null when sending files\");\n        }\n        if (mediaType == null) {\n            throw new NullPointerException(\"Multipart field media type cannot be null\");\n        }\n        this.name = name;\n        this.value = null;\n        this.filename = filename;\n        this.pathname = null;\n        this.content = content;\n        this.multiByteContent = null;\n        this.mediaType = mediaType;\n        this.text = text;\n        this.isObject = false;\n        this.type = null;\n    }\n\n    public String name() {\n        return name;","sourceCodeStart":104,"sourceCodeEnd":140,"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#L104-L140","documentation":"This NullPointerException is thrown by the Buffer-based QuarkusMultipartFormDataPart constructor when the content parameter is null. An in-memory multipart part must have actual bytes to encode; a null Buffer cannot be written into the request body. The constructor fails fast before any network activity.","triggerScenarios":"Calling QuarkusMultipartFormDataPart(name, filename, (Buffer) null, mediaType, text) or MultipartForm.binaryFileUpload(name, filename, (Buffer) null, mediaType) with a null Buffer.","commonSituations":"Buffer.buffer(...) built from a byte[] that is null; an async load (fileSystem.readFile) whose result was not yet assigned/failed silently; mapping an Optional<byte[]> that was empty to null.","solutions":["Ensure the Buffer is created before the call, e.g. Buffer.buffer(bytes) with a non-null byte[]","Handle the async read completion before building the multipart form","If content may legitimately be absent, skip adding the part rather than passing a null Buffer"],"exampleFix":"// before\nbyte[] bytes = loadBytes(); // may return null\nform.binaryFileUpload(\"file\", filename, Buffer.buffer(bytes), mime);\n// after\nbyte[] bytes = loadBytes();\nif (bytes != null) {\n    form.binaryFileUpload(\"file\", filename, Buffer.buffer(bytes), mime);\n}","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(bytes, \"content bytes must not be null\");\nBuffer content = Buffer.buffer(bytes);","typeGuard":"boolean hasContent(Buffer content) {\n    return content != null && content.length() > 0;\n}","tryCatchPattern":null,"preventionTips":["Wait for async file/data reads to complete before building the form","Map empty Optionals to 'skip part' rather than null content","Assert non-null byte[] results in service-layer tests"],"tags":["rest-client","multipart","null-check","buffer"],"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"}