500 error on diff of some MR: NoMethodError (undefined method `file_path' for #<String:0x00007faf3698ca28>)

Summary

Running on GitLab 11.6.10 (omnibus), when trying to display the diff from one of our MRs the server replies with a 500 error on diffs.json.

Steps to reproduce

Open diff in specific merge request. example url: https://gitlab.example.com/group/project/merge_requests/233/diffs

What is the current bug behavior?

500 on loading https://gitlab.example.com/group/project/merge_requests/233/diffs.json

Relevant logs and/or screenshots

Processing by Projects::MergeRequests::DiffsController#show as JSON
  Parameters: {"namespace_id"=>"group", "project_id"=>"project", "id"=>"233"}
Completed 500 Internal Server Error in 108ms (ActiveRecord: 14.9ms)
  
NoMethodError (undefined method `file_path' for #<String:0x00007faf3698ca28>):
  
lib/gitlab/diff/file_collection/base.rb:39:in `block in unfold_diff_files'
lib/gitlab/diff/file_collection/base.rb:39:in `each'
lib/gitlab/diff/file_collection/base.rb:39:in `group_by'
lib/gitlab/diff/file_collection/base.rb:39:in `unfold_diff_files'
app/controllers/projects/merge_requests/diffs_controller.rb:27:in `render_diffs'
app/controllers/projects/merge_requests/diffs_controller.rb:14:in `show'
lib/gitlab/i18n.rb:55:in `with_locale'
lib/gitlab/i18n.rb:61:in `with_user_locale'
app/controllers/application_controller.rb:420:in `set_locale'
lib/gitlab/middleware/multipart.rb:103:in `call'
lib/gitlab/request_profiler/middleware.rb:16:in `call'
lib/gitlab/middleware/go.rb:19:in `call'
lib/gitlab/etag_caching/middleware.rb:13:in `call'
lib/gitlab/middleware/correlation_id.rb:16:in `block in call'
lib/gitlab/correlation_id.rb:15:in `use_id'
lib/gitlab/middleware/correlation_id.rb:15:in `call'
lib/gitlab/middleware/read_only/controller.rb:40:in `call'
lib/gitlab/middleware/read_only.rb:18:in `call'
lib/gitlab/middleware/basic_health_check.rb:25:in `call'
lib/gitlab/request_context.rb:20:in `call'
lib/gitlab/metrics/requests_rack_middleware.rb:29:in `call'
lib/gitlab/middleware/release_env.rb:13:in `call'
Processing by Projects::MergeRequestsController#ci_environments_status as JSON
  Parameters: {"namespace_id"=>"group", "project_id"=>"project", "id"=>"233"}
Processing by Projects::MergeRequestsController#discussions as JSON
  Parameters: {"namespace_id"=>"group", "project_id"=>"project", "id"=>"233"}

I tried to look for the cause of the error and wrapped line 39 in to begin/rescue block to see content of positions variable:

        # This mutates `diff_files` lines.
        def unfold_diff_files(positions)
          begin
            positions_grouped_by_path = positions.group_by { |position| position.file_path }
          rescue
            raise positions.map{|i| "'#{i}'"}.join("\n")
          end
RuntimeError ('{"base_sha":"52f0b6cc23cd954270350719e4f979c876406dc7","start_sha":null,"head_sha":"9295621e95ea5be588aa9574515195518502f902","old_path":"path/to/file.txt","new_path":"path/to/file.txt","position_type":"text","old_line":162,"new_line":null}'
'{"base_sha":"52f0b6cc23cd954270350719e4f979c876406dc7","start_sha":null,"head_sha":"9295621e95ea5be588aa9574515195518502f902","old_path":"path/to/file.txt","new_path":"path/to/file.txt","position_type":"text","old_line":178,"new_line":null}'
'{"base_sha":"52f0b6cc23cd954270350719e4f979c876406dc7","start_sha":null,"head_sha":"9295621e95ea5be588aa9574515195518502f902","old_path":"path/to/file.txt","new_path":"path/to/file.txt","position_type":"text","old_line":105,"new_line":105}'):

There are json strings instead of objects and there is no file_path property. Only old_path and new_path (values are the same).

Results of GitLab environment info

Expand for output related to GitLab environment info
System information
System:		Debian 7.0
Current User:	git
Using RVM:	no
Ruby Version:	2.5.3p105
Gem Version:	2.7.6
Bundler Version:1.16.6
Rake Version:	12.3.2
Redis Version:	3.2.12
Git Version:	2.18.1
Sidekiq Version:5.2.3
Go Version:	unknown

GitLab information Version: 11.6.10 Revision: c6b7579 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql URL: https://gitlab.example.com HTTP Clone URL: https://gitlab.example.com/some-group/some-project.git SSH Clone URL: git@gitlab.example.com:some-group/some-project.git Using LDAP: no Using Omniauth: yes Omniauth Providers:

GitLab Shell Version: 8.4.3 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

Expand for output related to the GitLab application check
Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 8.4.3 ? ... OK (8.4.3) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Redis available via internal API: OK

Access to /var/opt/gitlab/.ssh/authorized_keys: OK gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab App ...

Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 6/4 ... yes 2/7 ... yes 18/8 ... yes 6/9 ... yes 33/10 ... yes 18/11 ... yes 25/12 ... yes 8/13 ... yes 8/14 ... yes 44/15 ... yes 44/16 ... yes 44/17 ... yes 44/18 ... yes 44/19 ... yes 18/20 ... yes 26/21 ... yes 18/22 ... yes 18/23 ... yes 58/24 ... yes 58/25 ... yes 58/27 ... yes 58/28 ... yes 58/29 ... yes 65/30 ... yes 65/31 ... yes 36/33 ... yes 36/34 ... yes 66/35 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.3.5 ? ... yes (2.5.3) Git version >= 2.18.0 ? ... yes (2.18.1) Git user has default SSH configuration? ... yes Active users: ... 42

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished