{"record":{"id":"c1be622226a2eda2","repo":"halo-dev/halo","slug":"no-file-part-found-in-the-request","errorCode":null,"errorMessage":"No file part found in the request","messagePattern":"No file part found in the request","errorType":"validation","errorClass":"ServerWebInputException","httpStatus":400,"severity":"error","filePath":"application/src/main/java/run/halo/app/core/endpoint/console/UserEndpoint.java","lineNumber":401,"sourceCode":"                        })\n                        .retryWhen(Retry.backoff(5, Duration.ofMillis(100))\n                                .filter(OptimisticLockingFailureException.class::isInstance)))\n                .flatMap(user -> ServerResponse.ok().bodyValue(user));\n    }\n\n    /** Multipart payload for uploading a user avatar. */\n    @Schema(types = \"object\")\n    public interface IAvatarUploadRequest {\n        /** Avatar file. */\n        @Schema(requiredMode = REQUIRED)\n        FilePart getFile();\n    }\n\n    public record AvatarUploadRequest(MultiValueMap<String, Part> formData) {\n        public FilePart getFile() {\n            Part file = formData.getFirst(\"file\");\n            if (file == null) {\n                throw new ServerWebInputException(\"No file part found in the request\");\n            }\n\n            if (!(file instanceof FilePart filePart)) {\n                throw new ServerWebInputException(\"Invalid part of file\");\n            }\n\n            boolean isNoneExt = Arrays.stream(ALLOWED_AVATAR_EXTENSIONS)\n                    .noneMatch(ext -> filePart.filename().endsWith(\".\" + ext));\n\n            if (isNoneExt) {\n                throw new ServerWebInputException(\n                        \"Only support file with extension: \" + String.join(\", \", ALLOWED_AVATAR_EXTENSIONS));\n            }\n            return filePart;\n        }\n    }\n\n    private Mono<Attachment> uploadAvatar(AvatarUploadRequest uploadRequest) {","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/halo-dev/halo/blob/d2f5165f9c8f055ffcb3fa9c3f4032821a7b68c8/application/src/main/java/run/halo/app/core/endpoint/console/UserEndpoint.java#L383-L419","documentation":"Thrown as a ServerWebInputException (HTTP 400) by AvatarUploadRequest.getFile() when formData.getFirst(\"file\") returns null — i.e. the multipart request to the avatar upload endpoint contains no part named 'file' at all.","triggerScenarios":"POST to the user-center/console avatar upload endpoint with a multipart body that omits the 'file' field, or sends the file under a different field name (e.g. 'avatar', 'image', 'upload').","commonSituations":"Frontend uses the wrong form field name; the file picker returned no selection and the form was still submitted; a curl/Postman request forgot the -F 'file=@...' part; integration test posts an empty multipart body.","solutions":["Ensure the multipart request includes a part literally named 'file' containing the avatar binary.","Double-check the client-side field name matches 'file' exactly.","Verify the request Content-Type is multipart/form-data and the boundary is present."],"exampleFix":"// before: curl -F avatar=@me.png /users/-/avatar\n// after:  curl -F file=@me.png   /users/-/avatar","handlingStrategy":"validation","validationCode":"// ensure a File (or FormData File entry) is selected before submit\nif (selectedFile == null) {\n    showUserError(\"Select an avatar file first\");\n    return;\n}\nformData.append(\"file\", selectedFile); // exact field name 'file'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use the exact field name 'file' for avatar uploads.","Disable the submit button until a file is selected."],"tags":["user","avatar","upload","multipart","validation"],"backgroundTag":null,"analyzedSha":"d2f5165f9c8f055ffcb3fa9c3f4032821a7b68c8","analyzedAt":"2026-08-14T00:18:38.915Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}