ActionView::Template::Error (no implicit conversion of nil into String) when commit contains binary avro datafile

Summary

ActionView::Template::Error (no implicit conversion of nil into String) when attempting to view changes in large merge request

Steps to reproduce

  • Add an empty avro datafile to a repository
  • Push the changes to a gitlab server
  • Navigate to the diff of the commit in gitlab

See diegov_moneymate/gitlab-issue-32246@4a6dadb3 for an example of the error.

What is the current bug behavior?

  • The screen displays a message that reads "An error occurred while fetching this tab."
  • The "Changes" tab is selected, but is empty

What is the expected correct behavior?

  • The "Changes" tab is selected and shows the diff between the source and destination branches

Relevant logs and/or screenshots

In gitlab-rails/production.log

Completed 500 Internal Server Error in 998ms (ActiveRecord: 6.4ms)

ActionView::Template::Error (no implicit conversion of nil into String):
    16:           Click to expand it.
    17:     - elsif diff_file.diff_lines.length > 0
    18:       - total_lines = 0
    19:       - if blob.lines.any?
    20:         - total_lines = blob.lines.last.chomp == '' ? blob.lines.size - 1 : blob.lines.size
    21:       - if diff_view == :parallel
    22:         = render "projects/diffs/parallel_view", diff_file: diff_file, total_lines: total_lines
  app/views/projects/diffs/_content.html.haml:19:in `_app_views_projects_diffs__content_html_haml__469176773470834162_70132993163060'
  app/views/projects/diffs/_file.html.haml:21:in `_app_views_projects_diffs__file_html_haml___3378667224025290190_70132999422140'
  app/views/projects/diffs/_diffs.html.haml:33:in `block in _app_views_projects_diffs__diffs_html_haml__4337802530259052801_70132979828560'
  lib/gitlab/git/diff_collection.rb:29:in `each'
  lib/gitlab/git/diff_collection.rb:29:in `each'
  app/views/projects/diffs/_diffs.html.haml:26:in `each_with_index'
  app/views/projects/diffs/_diffs.html.haml:26:in `_app_views_projects_diffs__diffs_html_haml__4337802530259052801_70132979828560'
  app/views/projects/merge_requests/show/_diffs.html.haml:3:in `_app_views_projects_merge_requests_show__diffs_html_haml__605655972088185962_70132987662140'
  app/controllers/application_controller.rb:192:in `view_to_html_string'
  app/controllers/projects/merge_requests_controller.rb:132:in `block (2 levels) in diffs'
  app/controllers/projects/merge_requests_controller.rb:101:in `diffs'
  lib/gitlab/middleware/multipart.rb:93:in `call'
  lib/gitlab/request_profiler/middleware.rb:14:in `call'
  lib/gitlab/middleware/go.rb:16:in `call'
  lib/gitlab/etag_caching/middleware.rb:10:in `call'
  lib/gitlab/request_context.rb:18:in `call'

The diff is pretty large though I'm not sure if that makes a difference, we've merged large changes in other projects in the same gitlab instance before.

$ git diff master | wc -l
6836

Output of checks

Sorry, I'm not sure what goes here. Let me know what I need to add.

Results of GitLab environment info

System information
System:		Debian 7.11
Current User:	git
Using RVM:	no
Ruby Version:	2.3.3p222
Gem Version:	2.6.6
Bundler Version:1.13.7
Rake Version:	10.5.0
Redis Version:	3.2.5
Git Version:	2.11.1
Sidekiq Version:4.2.7

GitLab information
Version:	9.1.0
Revision:	c3f0f14
Directory:	/opt/gitlab/embedded/service/gitlab-rails
DB Adapter:	postgresql
URL:		****
HTTP Clone URL:	****
SSH Clone URL:	****
Using LDAP:	yes
Using Omniauth:	no

GitLab Shell
Version:	5.0.2
Repository storage paths:
- default: 	/var/opt/gitlab/git-data/repositories
Hooks:		/opt/gitlab/embedded/service/gitlab-shell/hooks
Git:		/opt/gitlab/embedded/bin/git

Results of GitLab application Check

The check outputs some confidential information so I'll just paste here the only issue it flagged:

Uploads directory setup correctly? ... no
  Try fixing it:
  sudo chown -R git /var/opt/gitlab/gitlab-rails/uploads
  sudo find /var/opt/gitlab/gitlab-rails/uploads -type f -exec chmod 0644 {} \;
  sudo find /var/opt/gitlab/gitlab-rails/uploads -type d -not -path /var/opt/gitlab/gitlab-rails/uploads -exec chmod 0700 {} \;
  For more information see:
  doc/install/installation.md in section "GitLab"
  Please fix the error above and rerun the checks.

I fixed the directory permissions, restarted gitlab, and the gitlab check now doesn't report any issues, but the merge request error persists.