Skip to content
Snippets Groups Projects

Resolve "Error 500 loading merge request: undefined method `index' for nil:NilClass"

1 unresolved thread
3 files
+ 17
0
Compare changes
  • Side-by-side
  • Inline
Files
3
  • It appears that some legacy diff notes on GitLab.com have invalid line codes,
    which means truncated_diff_lines won't work. This is just a band-aid solution,
    as neither the diff nor the discussion will display correctly for these notes,
    but they won't cause a 500 error.
@@ -37,6 +37,8 @@ def on_merge_request_commit?
# Returns an array of at most 16 highlighted lines above a diff note
def truncated_diff_lines(highlight: true)
return [] if diff_line.nil? && first_note.is_a?(LegacyDiffNote)
lines = highlight ? highlighted_diff_lines : diff_lines
initial_line_index = [diff_line.index - NUMBER_OF_TRUNCATED_DIFF_LINES + 1, 0].max
Loading