Error 500 creating diff note (comment) - hide whitespace mode
Scenario 1 (review): Steps:
- Go to jay_mccure/bug_triage!1 (diffs)
- Change settings to be
Side by side
and do not show whitespace (bug can also occur ininline
mode also. - Start a review with a comment on line 54 (right hand side)
- Finish Review -> Submit review
Actual outcome:
- 500 error occurs from
/publish
- Comment is actually submitted, but it is also pending and the review is still open
- Other comments in the review are lost
- Deleting the comment that was submitted requires the user to delete the comment AND refresh the page to remove it.
Scenario 2 (add comment now):
- Go to jay_mccure/bug_triage!1 (diffs)
- Change settings to be
Side by side
and do not show whitespace - Add an immediate comment on line 54 (right hand side)
Actual outcome:
- 500 error occurs from
/notes
- Overview page fails to show diff for comment (see screenshot below)
- Deleting the comment that was submitted requires the user to delete the comment AND refresh the page to remove it.
Other symptoms
- The diff for the comment fails to load in the overview page.
Try Again
does nothing.
- Comments on whitespace can get hidden see: #800 (closed)
Request to `/drafts`
{
"view": "parallel",
"line_type": "old",
"merge_request_diff_head_sha": "1e617cd264d281b92eb93e97cc015572a0c6135a",
"in_reply_to_discussion_id": "",
"note_project_id": "",
"target_type": "merge_request",
"target_id": 176052042,
"return_discussion": true,
"draft_note":
{
"note": "fd",
"position": "{\"base_sha\":\"1b35335879ed1f25044ebcde2b50c9fb451a1976\",\"start_sha\":\"1b35335879ed1f25044ebcde2b50c9fb451a1976\",\"head_sha\":\"1e617cd264d281b92eb93e97cc015572a0c6135a\",\"old_path\":\"500_comment_test.rb\",\"new_path\":\"500_comment_test.rb\",\"position_type\":\"text\",\"old_line\":null,\"new_line\":54,\"line_range\":{\"start\":{\"line_code\":\"28827ed01984e87b49208380e411ccab758513f8_37_54\",\"type\":\"new\",\"old_line\":null,\"new_line\":54},\"end\":{\"line_code\":\"28827ed01984e87b49208380e411ccab758513f8_37_54\",\"type\":\"new\",\"old_line\":null,\"new_line\":54}}}",
"noteable_type": "MergeRequest",
"noteable_id": 176052042,
"commit_id": null,
"type": "DiffNote",
"line_code": "28827ed01984e87b49208380e411ccab758513f8_37_54"
}
}
Response from `/drafts`
{
"id": 19738888,
"author":
{
"id": 11809982,
"username": "jay_mccure",
"name": "Jay McCure",
"state": "active",
"avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/11809982/avatar.png",
"status_tooltip_html": null,
"show_status": false,
"availability": null,
"path": "/jay_mccure"
},
"merge_request_id": 176052042,
"position":
{
"base_sha": "1b35335879ed1f25044ebcde2b50c9fb451a1976",
"start_sha": "1b35335879ed1f25044ebcde2b50c9fb451a1976",
"head_sha": "3b17b67d51dfbb19dc27886bb037194739e98c23",
"old_path": "500_comment_test.rb",
"new_path": "500_comment_test.rb",
"position_type": "text",
"old_line": 84,
"new_line": 54,
"line_range":
{
"start":
{
"line_code": "28827ed01984e87b49208380e411ccab758513f8_37_54",
"type": "new",
"old_line": null,
"new_line": 54
},
"end":
{
"line_code": "28827ed01984e87b49208380e411ccab758513f8_37_54",
"type": "new",
"old_line": null,
"new_line": 54
}
}
},
"line_code": "28827ed01984e87b49208380e411ccab758513f8_37_54",
"file_identifier_hash": "6b80226da38a9a0ecf6ac5004b967aa864e1d117",
"file_hash": "28827ed01984e87b49208380e411ccab758513f8",
"file_path": "500_comment_test.rb",
"note": "fd",
"note_html": "<p data-sourcepos=\"1:1-1:2\" dir=\"auto\">fd</p>",
"references":
{
"users":
[],
"commands": ""
},
"discussion_id": null,
"resolve_discussion": false,
"noteable_type": "MergeRequest",
"current_user":
{
"can_edit": true,
"can_award_emoji": false,
"can_resolve": false
}
}
- When using
/submit_review
quick action a confusing error is displayed and the/submit_review
comment also fails
Sentry suspects !68045 (merged).
https://sentry.gitlab.net/gitlab/gitlabcom/issues/2765545/?referrer=gitlab_plugin
DiffNote::NoteDiffFileCreationError: Failed to find diff line for: spec/lib/release_tools/promotion/status_note_spec.rb, old_line: , new_line: 42
app/models/diff_note.rb:46:in `create_diff_file'
raise NoteDiffFileCreationError, DIFF_LINE_NOT_FOUND_MESSAGE % {
lib/gitlab/metrics/instrumentation.rb:160:in `block in create_diff_file'
.measure { super }
lib/gitlab/metrics/method_call.rb:27:in `measure'
retval = yield
lib/gitlab/metrics/instrumentation.rb:160:in `create_diff_file'
.measure { super }
config/initializers/forbid_sidekiq_in_transactions.rb:52:in `block in committed!'
Sidekiq::Worker.skipping_transaction_check { super }
...
(179 additional frame(s) were not displayed)
Proposal
This issue tracks the mitigation of the data loss caused in this scenario.
We'll go ahead with:
- Disabling adding comments when seeing the diff with Show whitespace changes turned off.
We'll have a follow-up issue to add support for commenting in this diff mode: #398186 (closed)
Edited by Kai Armstrong