Affects Version/s: 7.4.5
Fix Version/s: None
Repro on vanilla XWiki 7.4.5 install, which uses a Maximum File Size limit of 32.0 MiB, or 33554432 bytes:
1. Create a file that is exactly 32.0 MiB. On MacOS this can be done with: mkfile $((32 * 1024 * 1024)) ~/32mb.out
2. Upload the file as an attachment to XWiki.
3. Observe generic server error: "An error occurred while uploading 32mb.out"
4. Generate a 33.0 MiB file and try uploading it.
5. Observe specific correct user-friendly error: The file 33mb.out is too large. Please choose files under 32.0 mb"
The above can be repeated with different file sizes and the following pattern is then seen:
SIZE_LIMIT - 500 bytes: upload is successful
SIZE_LIMIT - 384 bytes: An error occurred while uploading <filename>
SIZE_LIMIT bytes: An error occurred while uploading <filename>
SIZE_LIMIT + 128 bytes: An error occurred while uploading <filename>
SIZE_LIMIT + 1024 bytes: The file <filename> is too large. Please choose files under 32.0 mb"
I haven't done a full analysis to discover precisely in what range of values the generic error gets produced, but it definitely seems to only be a problem if the uploaded file is within <= 1024 bytes of the Maximum File Size setting.
From a user perspective this is problematic because the error message doesn't tell them why their upload failed. I think the desired behavior is either that the upload succeeds or you get the user-friendly "is too large" error.