Skip to content

MR Review code comments get lost / can't be submitted on unchanged lines

I've "lost" comments in two MRs where I've commented on an unchanged line and had to re-type them, there was no hint that the messages weren't saved when submitting the review; unsure if this is expected (we should disallow commenting on unchanged lines if that's the case).

If manually trying to add a comment on that same line (not through a review), it fails with a 422 error from GraphQL with:

{"commands_changes":null,"valid":false,"errors":{"line_code":["can't be blank","must be a valid line code"]}}

The two full GraphQL requests for those lines were:

For !83350 (diffs),

{"view":"inline","line_type":"old","merge_request_diff_head_sha":"58ba26ee5845ddfa8207a197e421591a17043b56","in_reply_to_discussion_id":"","note_project_id":"","target_type":"merge_request","target_id":146227003,"return_discussion":true,"note":{"note":"Test - ignore this comment","position":"{\"base_sha\":\"0229307b5f71e3c1390bdee83a272205f09ffdba\",\"start_sha\":\"0229307b5f71e3c1390bdee83a272205f09ffdba\",\"head_sha\":\"58ba26ee5845ddfa8207a197e421591a17043b56\",\"old_path\":\"lib/gitlab/patch/legacy_database_config.rb\",\"new_path\":\"lib/gitlab/patch/database_config.rb\",\"position_type\":\"text\",\"old_line\":87,\"new_line\":99,\"line_range\":{\"start\":{\"line_code\":\"428003eb8f1d10f238a231844ddf40b948693345_87_99\",\"type\":null,\"old_line\":87,\"new_line\":99},\"end\":{\"line_code\":\"428003eb8f1d10f238a231844ddf40b948693345_87_99\",\"type\":null,\"old_line\":87,\"new_line\":99}}}","noteable_type":"MergeRequest","noteable_id":146227003,"commit_id":null,"type":"DiffNote","line_code":"428003eb8f1d10f238a231844ddf40b948693345_87_99"}}

And for !83251 (diffs) (I expanded 20 lines above and tried saving):

{"view":"parallel","line_type":"old","merge_request_diff_head_sha":"1dcf86cdf7c7d0eccfec92956fefd4ce2f5728db","in_reply_to_discussion_id":"","note_project_id":"","target_type":"merge_request","target_id":145984993,"return_discussion":true,"note":{"note":"test comment","position":"{\"base_sha\":\"cb4f76e024d2518c393b1581d71df2cb321a2248\",\"start_sha\":\"cb4f76e024d2518c393b1581d71df2cb321a2248\",\"head_sha\":\"1dcf86cdf7c7d0eccfec92956fefd4ce2f5728db\",\"old_path\":\"db/structure.sql\",\"new_path\":\"db/structure.sql\",\"position_type\":\"text\",\"old_line\":11980,\"new_line\":11980,\"line_range\":{\"start\":{\"line_code\":\"2b082fc1831991d48d393026c0c6a4283cb3d159_11979_11979\",\"type\":null,\"old_line\":11979,\"new_line\":11979},\"end\":{\"line_code\":\"2b082fc1831991d48d393026c0c6a4283cb3d159_11980_11980\",\"type\":null,\"old_line\":11980,\"new_line\":11980}}}","noteable_type":"MergeRequest","noteable_id":145984993,"commit_id":null,"type":"DiffNote","line_code":"2b082fc1831991d48d393026c0c6a4283cb3d159_11980_11980"}}