Fix MissingTemplate error in Gitaly error handler
What does this MR do and why?
Fixes a 500 ActionView::MissingTemplate error raised when Gitaly is
unavailable during rapid diffs requests.
HandlesGitalyErrors#handle_gitaly_error responds to HTML requests with
render action: action_name, which assumes every action has a template.
Streaming and component-rendering actions have none. The rapid diffs
diffs_stream and diff_file actions stream directly or render
ViewComponents, so a Gitaly error there raised
ActionView::MissingTemplate.
The fix checks template_exists? first and falls back to a plain-text
503 carrying the existing Gitaly-unavailable message.
How to set up and validate locally
-
Stop Gitaly:
gdk stop gitaly -
Request a compare diffs stream, for example
http://gdk.test:3000/gitlab-org/gitlab-test/-/compare/diffs_stream?from=master&to=feature&straight=true -
Before this change the response is a
500(ActionView::MissingTemplate). After it, a503with the Gitaly-unavailable message. -
Restart Gitaly:
gdk start gitaly
Or run the specs:
bin/rspec spec/controllers/concerns/handles_gitaly_errors_spec.rb
bin/rspec spec/requests/projects/compare_diffs_stream_controller_spec.rb
bin/rspec spec/controllers/projects/compare_controller_spec.rbMR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.