{"record":{"id":"3ed75d6fa10a3f9c","repo":"quarkusio/quarkus","slug":"multipart-field-name-pathname-cannot-be-null-when","errorCode":null,"errorMessage":"Multipart field name pathname cannot be null when sending files","messagePattern":"Multipart field name pathname 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":97,"sourceCode":"        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    }\n\n    public QuarkusMultipartFormDataPart(String name, String filename, Buffer content, String mediaType, boolean text) {\n        if (name == null) {","sourceCodeStart":79,"sourceCodeEnd":115,"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#L79-L115","documentation":"This NullPointerException is thrown by the file-path based QuarkusMultipartFormDataPart constructor when the pathname parameter is null. A file-backed multipart part needs a path to read the file content from at send time; without it the part cannot be encoded. The library validates all required parameters eagerly in the constructor.","triggerScenarios":"Calling QuarkusMultipartFormDataPart(name, filename, null, mediaType, text) or an API like MultipartForm.binaryFileUpload(name, filename, pathname, mediaType) with a null pathname argument.","commonSituations":"Config value or user-supplied path not set so the path variable is null; file-upload field from a web form left empty and the path forwarded unchecked; refactoring that swapped a content-based constructor for a path-based one without supplying a path.","solutions":["Pass a valid, non-null file path to binaryFileUpload / the constructor","Check that the source path variable is populated (e.g. from config or request) before building the multipart form","If there is no file on disk, use the content-based constructor with an in-memory Buffer instead"],"exampleFix":"// before\nString path = config.getOptionalValue(\"upload.path\", String.class).orElse(null);\nform.binaryFileUpload(\"file\", \"data.bin\", path, \"application/octet-stream\");\n// after\nString path = config.getValue(\"upload.path\", String.class);\nObjects.requireNonNull(path, \"upload.path must be set\");\nform.binaryFileUpload(\"file\", \"data.bin\", path, \"application/octet-stream\");","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(pathname, \"pathname is required for multipart file upload\");\nif (!Files.exists(Path.of(pathname))) {\n    throw new IllegalArgumentException(\"file does not exist: \" + pathname);\n}","typeGuard":"boolean hasValidPath(String pathname) {\n    return pathname != null && !pathname.isBlank() && Files.isRegularFile(Path.of(pathname));\n}","tryCatchPattern":null,"preventionTips":["Validate configuration values supplying the path at startup","Use Path objects from the start to avoid null Strings","For in-memory uploads use the Buffer constructor so no path is needed"],"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"}