Multi-line comment including "No newline at end of file" line fails
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
When a file is missing a new line char at the end of the file GitLab displays a \No newline at end of file
line in MRs. You cannot comment on them with a single-line comment, but they can be included in a multi-line comment, which fails.
Steps to reproduce
- Open MR with a new file which has no new line character at the end of file.
- Attempt a multi-line comment including line 18 and the line below:
- Click add to review, or comment now.
Example Project
gitlab-com/www-gitlab-com!126776 (diffs)
What is the current bug behavior?
Request:
{"view":"inline","line_type":"old","merge_request_diff_head_sha":"bc7e95c599724c6336608068ee9fb851fa8a7274","in_reply_to_discussion_id":"","note_project_id":"","target_type":"merge_request","target_id":235355862,"return_discussion":true,"draft_note":{"note":"test","position":"{\"base_sha\":\"728890fdcd9a6a8e8959e72e7987a016d2927c02\",\"start_sha\":\"728890fdcd9a6a8e8959e72e7987a016d2927c02\",\"head_sha\":\"bc7e95c599724c6336608068ee9fb851fa8a7274\",\"old_path\":\"data/release_posts/unreleased/govern-groupsubgroup-level-dependency-list--mvc.yml\",\"new_path\":\"data/release_posts/unreleased/govern-groupsubgroup-level-dependency-list--mvc.yml\",\"position_type\":\"text\",\"old_line\":null,\"new_line\":null,\"line_range\":{\"start\":{\"line_code\":\"d0b4adadcb4021e2c2b5b1f290b64f9c0b01b95b_0_17\",\"type\":\"new\",\"old_line\":null,\"new_line\":17},\"end\":{\"line_code\":null,\"type\":\"new-nonewline\",\"old_line\":null,\"new_line\":null}},\"ignore_whitespace_change\":false}","noteable_type":"MergeRequest","noteable_id":235355862,"commit_id":null,"type":"DiffNote","line_code":null}}
Response:
{"errors":"Position must be a valid json schema"}
What is the expected correct behavior?
No error
Edited by 🤖 GitLab Bot 🤖