Make Puma low-level handler return recommended status code
What does this merge request do and why?
Because of https://github.com/puma/puma/pull/3094, Puma v6.4.0 now returns the status code sent from the low-level handler instead of Puma's recommended status code. This caused malformed URLs to return a 500 error when previously it would return a 400 Bad Request error, which skewing error metrics.
Previously we had hard-coded low-level errors to return 500 status errors, but now we should adapt this to return the status code recommended by Puma.
Relates to gitlab-com/gl-infra/production#16417 (closed)
Related merge requests:
gitlab#426135 (closed) has been created to address this duplication.
How to set up and validate locally
With the current gitlab/config/puma.rb
:
$ curl -I 'http://gdk.test:3000/-/merge_requests?sort=created_date&state=<th:t=\"%24{dfb}%23foreach'
HTTP/1.1 500 Internal Server Error
Content-Length: 244
Date: Mon, 25 Sep 2023 14:50:50 GMT
Now:
- Run
bundle exec rake gitlab/config/puma.rb
. gdk restart rails-web
$ curl -I 'http://gdk.test:3000/-/merge_requests?sort=created_date&state=<th:t=\"%24{dfb}%23foreach'
HTTP/1.1 400 Bad Request
Date: Mon, 25 Sep 2023 14:41:36 GMT
Impacted categories
The following categories relate to this merge request:
-
gdk-reliability - e.g. When a GDK action fails to complete. -
gdk-usability - e.g. Improvements or suggestions around how the GDK functions. -
gdk-performance - e.g. When a GDK action is slow or times out.
Merge request checklist
-
This change is backward compatible. If not, please include steps to communicate to our users. -
Tests added for new functionality. If not, please raise an issue to follow-up. -
Documentation added/updated, if needed. -
Announcement added, if change is notable. -
gdk doctor
test added, if needed. -
Add the ~highlight
label if this MR should be included in theCHANGELOG.md
.
Edited by Stan Hu