workhorse: Downgrade incomplete multipart uploads to 400 errors
What does this MR do and why?
In gitlab-com/gl-infra/production#17587 (closed),
our 500 error rates rose when incomplete multipart uploads were sent,
but this is really a client error, not a server error. This commit
downgrades that to a 400 error by doing an ugly string comparison in
multipart.NextPart
to check for this condition.
How to set up and validate locally
Happy path
- Check out this branch.
- Compile
workhorse
by runningmake -C workhorse
from thegitlab
directory. gdk restart gitlab-workhorse
- Go to
/-/user_settings/profile
- Update profile photo
Error path
- Open your browser's
Inspect
to see the POST request. - Download the request data. It should something like:
-----------------------------16627824944090109022046164902
Content-Disposition: form-data; name="_method"
put
-----------------------------16627824944090109022046164902
Content-Disposition: form-data; name="authenticity_token"
SOME-TOKEN-HERE
-----------------------------16627824944090109022046164902
Content-Disposition: form-data; name="user[avatar]-trigger"; filename=""
Content-Type: application/octet-stream
- Save this request data to
/tmp/test.txt
. - Truncate the last character or two from the file.
- Issue the
curl
request using the sameContent-Type
header from the request:
curl -v -X POST -H "Content-Type: multipart/form-data; boundary=---------------------------16627824944090109022046164902" https://gdk.test:3000/-/user_settings/profile -d @/tmp/test.txt
- This should return
400 Bad Request
instead of500 Internal Server Error
.
Edited by Stan Hu