Skip to content

Fix LocalJumpError when an MR has no diff

Matthias Käppler requested to merge mk-fix-localjmperror into master

What does this MR do and why?

Discovered in Sentry while testing Ruby 3 compat (though this error is unrelated to Ruby 3).

We were breaking from a format block with break; the semantics of this in a proc is to return from the calling method, which can result in LocalJumpError being raised when that method has already returned, which seems to happen with render. One should break from procs using next instead.

This also had no test coverage, so I added some tests.

Error:

     LocalJumpError:
       break from proc-closure
     # ./app/controllers/projects/merge_requests_controller.rb:393:in `block (2 levels) in show_merge_request'
     # /data/cache/bundle-3.0.5/ruby/3.0.0/gems/actionpack-6.1.6.1/lib/action_controller/metal/mime_responds.rb:214:in `respond_to'
     # ./app/controllers/projects/merge_requests_controller.rb:364:in `show_merge_request'
     # ./app/controllers/projects/merge_requests_controller.rb:110:in `show'
...

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Matthias Käppler

Merge request reports