quarkusio/quarkus · error · NullPointerException
Multipart field name pathname cannot be null when sending fi
Error message
Multipart field name pathname cannot be null when sending files
What it means
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.
Source
Thrown at independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartFormDataPart.java:97
this.filename = filename;
this.pathname = null;
this.content = null;
this.multiByteContent = null;
this.mediaType = null;
this.text = false;
this.isObject = false;
this.type = null;
}
public QuarkusMultipartFormDataPart(String name, String filename, String pathname, String mediaType, boolean text) {
if (name == null) {
throw new NullPointerException("Multipart field name cannot be null");
}
if (filename == null) {
throw new NullPointerException("Multipart field name filename cannot be null when sending files");
}
if (pathname == null) {
throw new NullPointerException("Multipart field name pathname cannot be null when sending files");
}
if (mediaType == null) {
throw new NullPointerException("Multipart field media type cannot be null");
}
this.name = name;
this.value = null;
this.filename = filename;
this.pathname = pathname;
this.content = null;
this.multiByteContent = null;
this.mediaType = mediaType;
this.text = text;
this.isObject = false;
this.type = null;
}
public QuarkusMultipartFormDataPart(String name, String filename, Buffer content, String mediaType, boolean text) {
if (name == null) {View on GitHub (pinned to e1c734241f)
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
Example fix
// before
String path = config.getOptionalValue("upload.path", String.class).orElse(null);
form.binaryFileUpload("file", "data.bin", path, "application/octet-stream");
// after
String path = config.getValue("upload.path", String.class);
Objects.requireNonNull(path, "upload.path must be set");
form.binaryFileUpload("file", "data.bin", path, "application/octet-stream"); Defensive patterns
Strategy: validation
Validate before calling
Objects.requireNonNull(pathname, "pathname is required for multipart file upload");
if (!Files.exists(Path.of(pathname))) {
throw new IllegalArgumentException("file does not exist: " + pathname);
} Type guard
boolean hasValidPath(String pathname) {
return pathname != null && !pathname.isBlank() && Files.isRegularFile(Path.of(pathname));
} Prevention
- 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
When it happens
Trigger: Calling QuarkusMultipartFormDataPart(name, filename, null, mediaType, text) or an API like MultipartForm.binaryFileUpload(name, filename, pathname, mediaType) with a null pathname argument.
Common situations: 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.
Related errors
- Multipart field name filename cannot be null when sending fi
- Multipart field name content cannot be null when sending fil
- Wrong Vert.x context used for multipart upload. Expected: "
- PartType annotation is only supported on fields and (setter/
- Primitive types are not supported for multipart response map
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/3ed75d6fa10a3f9c.
Report an issue: GitHub.