{"record":{"id":"6f709d0e97691700","repo":"quarkusio/quarkus","slug":"multipart-field-name-filename-cannot-be-null-when","errorCode":null,"errorMessage":"Multipart field name filename cannot be null when sending files","messagePattern":"Multipart field name filename 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":94,"sourceCode":"        }\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) {\n            throw new NullPointerException(\"Multipart field name filename cannot be null when sending files\");\n        }\n        if (pathname == null) {\n            throw new NullPointerException(\"Multipart field name pathname 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 = 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    }","sourceCodeStart":76,"sourceCodeEnd":112,"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#L76-L112","documentation":"The Quarkus REST client multipart support throws this NullPointerException from the QuarkusMultipartFormDataPart(String name, String filename, String pathname, String mediaType, boolean text) constructor when the filename parameter is null. Every file-based multipart part must carry a filename because it is written into the Content-Disposition header of the part. The library fails fast rather than sending a malformed multipart body.","triggerScenarios":"Calling the constructor QuarkusMultipartFormDataPart(name, null, pathname, mediaType, text) with a null filename, or calling any higher-level API (e.g. MultipartForm binaryFileUpload/dataFileUpload variants) that forwards a null filename into this constructor.","commonSituations":"Building a multipart request where the filename is derived from a java.io.File or Path that was not normalized, or from a variable that is null; passing null explicitly because only the path seemed relevant; refactoring code that previously used a String path and losing the filename along the way.","solutions":["Pass a non-null filename (the file's base name) when creating the file upload part, e.g. new File(pathname).getName()","Ensure the MultipartForm API used is binaryFileUpload(name, filename, pathname, mediaType) with all four arguments supplied","Add a null/empty check on the filename variable before building the form"],"exampleFix":"// before\nString filename = null;\nform.binaryFileUpload(\"file\", filename, \"/tmp/data.bin\", \"application/octet-stream\");\n// after\nString filename = new File(\"/tmp/data.bin\").getName();\nform.binaryFileUpload(\"file\", filename, \"/tmp/data.bin\", \"application/octet-stream\");","handlingStrategy":"validation","validationCode":"if (filename == null || filename.isBlank()) {\n    throw new IllegalArgumentException(\"filename is required for multipart file upload\");\n}","typeGuard":"boolean hasValidFilename(String filename) {\n    return filename != null && !filename.isBlank();\n}","tryCatchPattern":null,"preventionTips":["Derive filenames with new File(path).getName() instead of passing raw nullable variables","Use IDE null-analysis or @NotNull annotations on upload helper parameters","Prefer the MultipartForm helper methods over constructing parts manually"],"tags":["rest-client","multipart","null-check","vertx"],"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"}