adding a MR comment on a part of the file not in diff corrupts comments and triggers a 500 error
Steps to reproduce
- Open a MR with a small diff on a large file
changestab, click on
show full file
- Add a comment on a line far from the MR diffs
- Comment is not saved (error on top of page)
- Reloading the MR page triggers an Unable to load comments message
In the logs:
NoMethodError (undefined method `index' for nil:NilClass): app/models/concerns/discussion_on_diff.rb:48:in `truncated_diff_lines' app/serializers/base_serializer.rb:16:in `represent' app/controllers/concerns/issuable_actions.rb:118:in `discussions' app/controllers/projects/merge_requests_controller.rb:214:in `discussions' lib/gitlab/i18n.rb:55:in `with_locale' lib/gitlab/i18n.rb:61:in `with_user_locale' app/controllers/application_controller.rb:434: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:20: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:26:in `call' lib/gitlab/metrics/requests_rack_middleware.rb:29:in `call' lib/gitlab/middleware/release_env.rb:13:in `call'
Trying to expand comments shows an unable to load diff message:
Workaround to be able to complete MR
I had to create an issue to resolve comments later to have comments resolved. Then I was able to merge the MR.
Gitlab on docker
GitLab 11.10.4 (62c464651d2) GitLab Shell 9.0.0 GitLab Workhorse v8.5.2 GitLab API v4 Ruby 2.5.3p105 Rails 220.127.116.11 PostgreSQL 9.6.11 Gitaly unix:/var/opt/gitlab/gitaly/gitaly.socket 1.34.1 -- Git version 2.18.1