Add correlation ID to 500 page response
Spin-off of #34037 (closed): as an MVC, we should inject the correlation ID into our 500 pages. It is already available in the X-Request-Id
header, but that isn't user-visible by default, and it's not available to JavaScript.
We currently allow limited customisation of error pages through nginx: https://docs.gitlab.com/omnibus/settings/nginx.html#custom-error-pages It works by writing the correct files on gitlab-ctl reconfigure
and using them as static pages.
For this change, however, we'd need a dynamic error page, because the correlation ID is unique to each request. There are a couple of options we could consider:
- nginx has
ngx_http_sub_module
. We already build with this module: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/12.3.0+ce.0/config/software/nginx.rb#L52. We don't currently use it but it was added deliberately: omnibus-gitlab#4183 (closed) - Do the content substitution in Workhorse. I think ideally we'd do this by also moving the error pages there, as otherwise you have three places to look. This is more flexible, and in theory easier, but is a bigger initial change.
- Do the substitution in Rails (the default 500 page is there: https://gitlab.com/gitlab-org/gitlab/blob/master/public%2F500.html).
Option 2 is the one I like the most as we maintain Workhorse. Whichever we do, it would be nice if we could resolve the tension that custom pages are served by nginx, and default pages are served by Rails.