[BUG] Handling of HTTP response code 413
Actual behaviour
Android App version dated 25. of May 2023, version 4.0.
I try to upload a image to the OC server. And get a "unknown error" message. I google. I set php upload limits. The error message persists.
I enable server side debug logging. No direct clues there. I enable client side logging. Aha!
D: 2023-07-10 21:43:16:842(FileRequestBody.kt:70) .writeTo()File with name IMG_20230710_213046.jpg and size 2385151 written in request body
D: 2023-07-10 21:43:16:842(LogBuilder.kt:38) .logHttp()[Network, response] [info] [3651f353-788b-4a52-8caa-30f0faf8a0d2] Method: PUT URL: https://oc.langfeldt.net/remote.php/dav/files/Nicolai/Photos/IMG_202307\
10_213046.jpg Code: 413 Message: Request Entity Too Large
D: 2023-07-10 21:43:16:843(LogBuilder.kt:38) .logHttp()[Network, response] [header] [3651f353-788b-4a52-8caa-30f0faf8a0d2] Server: nginx/1.18.0 (Ubuntu)
D: 2023-07-10 21:43:16:844(LogBuilder.kt:38) .logHttp()[Network, response] [header] [3651f353-788b-4a52-8caa-30f0faf8a0d2] Date: Mon, 10 Jul 2023 19:42:48 GMT
D: 2023-07-10 21:43:16:844(LogBuilder.kt:38) .logHttp()[Network, response] [header] [3651f353-788b-4a52-8caa-30f0faf8a0d2] Content-Type: text/html
D: 2023-07-10 21:43:16:845(LogBuilder.kt:38) .logHttp()[Network, response] [header] [3651f353-788b-4a52-8caa-30f0faf8a0d2] Content-Length: 192
D: 2023-07-10 21:43:16:845(LogBuilder.kt:38) .logHttp()[Network, response] [header] [3651f353-788b-4a52-8caa-30f0faf8a0d2] Connection: close
D: 2023-07-10 21:43:16:846(LogBuilder.kt:38) .logHttp()[Network, response] [body] [3651f353-788b-4a52-8caa-30f0faf8a0d2] Length: 192 byte body
D: 2023-07-10 21:43:16:848(LogBuilder.kt:38) .logHttp()[Network, response] [body] [3651f353-788b-4a52-8caa-30f0faf8a0d2] Type: text/html
D: 2023-07-10 21:43:16:849(LogBuilder.kt:38) .logHttp()[Network, response] [body] [3651f353-788b-4a52-8caa-30f0faf8a0d2] --> Body start for response
D: 2023-07-10 21:43:16:850(LogBuilder.kt:38) .logHttp()[Network, response] [body] [3651f353-788b-4a52-8caa-30f0faf8a0d2] <html>^M
<head><title>413 Request Entity Too Large</title></head>^M
<body>^M
<center><h1>413 Request Entity Too Large</h1></center>^M
<hr><center>nginx/1.18.0 (Ubuntu)</center>^M
</body>^M
</html>^M
D: 2023-07-10 21:43:16:850(LogBuilder.kt:38) .logHttp()[Network, response] [body] [3651f353-788b-4a52-8caa-30f0faf8a0d2] <-- Body end for response -- Omitted: 0 bytes
D: 2023-07-10 21:43:16:852(RemoteOperationResult.java:320) .<init>()RemoteOperationResult has processed UNHANDLED_HTTP_CODE: 413 Request Entity Too Large
I: 2023-07-10 21:43:16:853(UploadFileFromFileSystemOperation.kt:79) .run()Upload of /storage/emulated/0/Android/data/com.owncloud.android/cache/IMG_20230710_213046.jpg to /Photos/IMG_20230710_213046.jpg: Opera\
tion finished with HTTP status code 413 (fail)
The unknown error is a Unhandled HTTP Code 413. From the server signature I'm forced to realize that we use a nginx reverse proxy as ingress controller and this proxy has not gotten the upload size enlarged. A client_max_body_size 16G; is needed.
Expected behaviour
A better error message based on the 413 response code. If it includes the server signature this might help the operator to trace the problem better.
Steps to reproduce
- Install OC, enlarge all upload limits
- Install nginx as a reverse proxy ingress controller in front of OC, with default upload limits
- Witness 413 error code.
Can this problem be reproduced with the official owncloud server? (url: https://demo.owncloud.org, user: test, password: test)
Environment data
Android version: 12 Device model: Fairphone 4 Stock or customized system: Stock ownCloud app version: 4.0 ownCloud server version: 10.12.2
Logs
Web server error log
Nothing interesing here as problem request never reached apache
ownCloud log (data/owncloud.log)
Nothing interesting here as requrest never even reached the apache in front
Thanks for your feedback.
Could you post a screenshot of the current error you see?
What do you mean with “server signature” in an improved error message? Do you have examples from other apps?
Error exists in our constant list:
https://github.com/owncloud/android-library/blob/063c3fa9e967e77e63f7f74259700e1c26a1d1fb/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/HttpConstants.java#L168
but not handled, your are right.
Hi,
This is the server signature (from the HTTP response headers): Server: nginx/1.18.0 (Ubuntu) - this will help a ops person figure out what system gave the error message more easily. Most companies and many private installations will have a border-reverse proxy such as nginx, haproxy, varnish, something from BigIP etc, which relays http requests to the right origin server, e.g. the owncloud server. Any of these might enforce a size restriction.
@yunal i get your point, in any case we should handle errors from the app, no matter which middleware are installed between client and server. We'll review.