Handle an exception when Git blame is out of range

What does this MR do and why?

Contributes to #425013 (closed)

Problem

Gitaly error handling behavior has changed for blame RPC: gitaly!6293 (merged)

Before it was silently catching errors and returning an empty result.

Now it responds with an exception.

Solution

Ideally, Gitaly should return a new error type for out of range errors that Rails can handle. But for now, Rails can catch GRPC::Internal error to restore the previous behavior.

Switch to structured errors will occur when Gitaly part is ready: gitaly#5594 (closed)

Screenshots or screen recordings

Before After
Screenshot_2023-09-13_at_15.18.50 Screenshot_2023-09-13_at_15.17.02

How to set up and validate locally

  1. Visit http://127.0.0.1:3000/api/v4/projects/2/repository/files/README.md/blame?ref=master&range[start]=999&range[end]=1000
  2. You should see an empty array result instead of Internal server error.

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 Vasilii Iakliushin

Merge request reports

Loading