Skip to content

Commit d00fdf5

Browse files
committed
Make Puma low-level handler return recommended status code
Because of puma/puma#3094, Puma v6.4.0 now returns the status code sent from the low-level handler instead of Puma's recommended status code. Previously we hard-coded low-level errors to return a 500 error, but now we should adapt this to return the status code recommended by Puma. Relates to https://gitlab.com/gitlab-com/gl-infra/production/-/issues/16417 Changelog: fixed
1 parent 607ec5f commit d00fdf5

File tree

1 file changed

+7
-3
lines changed
  • files/gitlab-cookbooks/gitlab/templates/default

1 file changed

+7
-3
lines changed

files/gitlab-cookbooks/gitlab/templates/default/puma.rb.erb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,15 @@ log_formatter do |str|
120120
json_formatter.call(str)
121121
end
122122

123-
lowlevel_error_handler do |ex, env|
123+
lowlevel_error_handler do |ex, env, status_code|
124+
# Puma v6.4.0 added the status_code argument in
125+
# https://github.com/puma/puma/pull/3094
126+
status_code ||= 500
127+
124128
if Raven.configuration.capture_allowed?
125-
Raven.capture_exception(ex, tags: { 'handler': 'puma_low_level' }, extra: { puma_env: env })
129+
Raven.capture_exception(ex, tags: { 'handler': 'puma_low_level' }, extra: { puma_env: env, status_code: status_code })
126130
end
127131

128132
# note the below is just a Rack response
129-
[500, {}, ["An error has occurred and reported in the system's low-level error handler."]]
133+
[status_code, {}, ["An error has occurred and reported in the system's low-level error handler."]]
130134
end

0 commit comments

Comments
 (0)