Fix NoMethodError for Projects::BlobController#diff_lines
What does this MR do and why?
Sentry error: https://new-sentry.gitlab.net/organizations/gitlab/issues/1794354
Problem
NoMethodError: undefined method `empty?' for nil:NilClass (NoMethodError)
return render_404 if diff_hunks.empty?
Code:
diff_hunks = Gitlab::Diff::ViewerHunk.init_from_expanded_lines(
presenter.diff_lines(with_positions_and_indent: true),
bottom,
closest_line_number
)
return render_404 if diff_hunks.empty?
ViewerHunk#init_from_expanded_lines returns nil instead of [].
Solution
Return [] to match expectation and resolve the error.
MR 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.
Edited by Vasilii Iakliushin