-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No originalFilename in MockMultipartFile now leads to add it just as part #26261
Comments
This seems to be a consequence of #25602. I'll revisit the assertions in |
This is likely impacted by the more recent change in #26166. There is also a separate new report https://github.com/spring-projects/spring-boot/issues/24483. |
Good catch, @rstoyanchev - so that effect seems to come from the intermediate |
Caused by bug in Spring MockMvc multipart file upload: spring-projects/spring-framework#26261
After a long debug session about the same problem after upgrading from Spring 5.2.12 to 5.3.2 and following git blame, I ended up here :-).
Just to clarify... (and document this for other people googling this issue): In version 5.3.2 this was always converted to a part, not just if the originalFilename was empty: Line 144 in 17e6cf1
In my case I first got a After giving the file an "originalFilename" I got an |
Thanks for the comment @yankee42 and sorry for the time spent. If you are able to verify the fix with |
I did so and confirm that this is fixed in 5.3.3-SNAPSHOT. |
is there a workaround for this issue on 2.4.1? I also get it for |
For me, using constructor with passing some originalFilename works.
|
When using
MockMultipartFile
with an emptyoriginalFilename
(""
), it now gets added to multi part requests just as a part, not as a file. When migrating from Spring Boot 2.3 to 2.4.1, this made myMockMvc
test fail for a controller using a@RequestPart MultipartFile
parameter causing a longer debugging session :-) It would be nice, if there had been a check (exception), that emptyoriginalFilename
s are no longer supported forMockMultipartFile
s.If the nullability of the
originalFilename
inMultipartFile
is intended,org.springframework.web.multipart.support.StandardMultipartHttpServletRequest#parseRequest
seems to be broken as it recognizes parts without filename not as files, so that they don't matchMultipartFile
parameters.The text was updated successfully, but these errors were encountered: