500 error when publishing MR review when comment made when showing whitespace
Summary
When a review contains a comment that:
- was made when showing whitespace
- was initiated from the right-hand-side of a side-by-side diff or on the bottom of an inline diff
- was made against a line that, when viewed in hide whitespace mode is unchanged (e.g. line 109 / line 134 / line 148 / line 107 in example MR) - unsure if this is the definitive reason why this bug is occurring
When the review is a submitted a 500 is returned from /publish and the review dialog box remains open. Any comment created after an affected comment will not be posted and will remain pending. Users then tend to re-submit which ends up with duplicate comments.
Sentry error - https://sentry.gitlab.net/gitlab/gitlabcom/issues/4103157/
Related: This started occurring after #338844 (closed) was fixed.
Steps to reproduce
- Go to jay_mccure/ws_2!6 (diffs) (this MR can be used for testing)
-
Showwhitespace / Turn on side-by-side comparison - Start a review with a comment on the right hand side line 109 (note: commenting on the left hand side 108 works as expected)
-
Finish review->Submit Review
Example Project
What is the current bug behavior?
- 500 from jay_mccure/ws_2!6 (closed)
- Example sentry: https://sentry.gitlab.net/gitlab/gitlabcom/issues/4103157/?query=user%3A%22username%3Ajay_mccure%22 e.g.
Failed to find diff line for: pipeline_multi_actions_spec.js, old_line: , new_line: 109 - Submit dialog box is still shown, which makes the user re-submit review which sends through duplicate commments
- Note: Comment is actually submitted
What is the expected correct behavior?
- Comment and review submitted
Output of checks
POST to drafts
{"view":"parallel","line_type":"old","merge_request_diff_head_sha":"e5084f8af60085bf6f7626db0844945cfe56b810","in_reply_to_discussion_id":"","note_project_id":"","target_type":"merge_request","target_id":228169346,"return_discussion":true,"draft_note":{"note":"a","position":"{\"base_sha\":\"461a14cea975c8a38869ac663c7a535535bb70e7\",\"start_sha\":\"461a14cea975c8a38869ac663c7a535535bb70e7\",\"head_sha\":\"e5084f8af60085bf6f7626db0844945cfe56b810\",\"old_path\":\"pipeline_multi_actions_spec.js\",\"new_path\":\"pipeline_multi_actions_spec.js\",\"position_type\":\"text\",\"old_line\":null,\"new_line\":109,\"line_range\":{\"start\":{\"line_code\":\"36076df0a44d4d62445bf8229f2d491737ca6e5d_111_109\",\"type\":\"new\",\"old_line\":null,\"new_line\":109},\"end\":{\"line_code\":\"36076df0a44d4d62445bf8229f2d491737ca6e5d_111_109\",\"type\":\"new\",\"old_line\":null,\"new_line\":109}},\"ignore_whitespace_change\":true}","noteable_type":"MergeRequest","noteable_id":228169346,"commit_id":null,"type":"DiffNote","line_code":"36076df0a44d4d62445bf8229f2d491737ca6e5d_111_109"}}
For reference this is POST to notes when commenting on the same line (which works fine).
{"view":"parallel","line_type":"new","merge_request_diff_head_sha":"e5084f8af60085bf6f7626db0844945cfe56b810","in_reply_to_discussion_id":"","note_project_id":"","target_type":"merge_request","target_id":228169346,"return_discussion":true,"note":{"note":"tt","position":"{\"base_sha\":\"461a14cea975c8a38869ac663c7a535535bb70e7\",\"start_sha\":\"461a14cea975c8a38869ac663c7a535535bb70e7\",\"head_sha\":\"e5084f8af60085bf6f7626db0844945cfe56b810\",\"old_path\":\"pipeline_multi_actions_spec.js\",\"new_path\":\"pipeline_multi_actions_spec.js\",\"position_type\":\"text\",\"old_line\":null,\"new_line\":109,\"line_range\":{\"start\":{\"line_code\":\"36076df0a44d4d62445bf8229f2d491737ca6e5d_111_109\",\"type\":\"new\",\"old_line\":null,\"new_line\":109},\"end\":{\"line_code\":\"36076df0a44d4d62445bf8229f2d491737ca6e5d_111_109\",\"type\":\"new\",\"old_line\":null,\"new_line\":109}},\"ignore_whitespace_change\":false}","noteable_type":"MergeRequest","noteable_id":228169346,"commit_id":null,"type":"DiffNote","line_code":"36076df0a44d4d62445bf8229f2d491737ca6e5d_111_109"}}
Originally identified: #338844 (comment 1408568151) (EDIT: Internal ZD ticket link: https://gitlab.zendesk.com/agent/tickets/411787)
Edited by Jay McCure