handle undefined position.line_range in case of comments on empty files #252
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #250
Example when the TypeError happens
{ "id": "e6b155b372d15d12fcd6b2ced5289313c8b178b5", "individual_note": false, "notes": [ { "id": 482339, "type": "DiffNote", "body": "empty file. I guess it should be removed from the PR.", "author": {...}, "created_at": "2025-10-27T10:40:33.686+01:00", "updated_at": "2025-10-27T13:24:19.959+01:00", "system": false, "noteable_id": 38062, "noteable_type": "MergeRequest", "project_id": 3336, "commit_id": null, "position": { "base_sha": "8017811eb76e7144a91f8e62daff8636f03e14d4", "start_sha": "8017811eb76e7144a91f8e62daff8636f03e14d4", "head_sha": "39ac4167acb2e01be9a0c4b50f0db2a3bd181939", "old_path": "src/ewoksutils/tests/cli_test_utils.py", "new_path": "src/ewoksutils/tests/cli_test_utils.py", "position_type": "file" }, "resolvable": true, "resolved": true, "resolved_by": {...}, "resolved_at": "2025-10-27T13:24:19.959+01:00", "suggestions": [], "confidential": false, "internal": false, "imported": false, "imported_from": "none", "noteable_iid": 58, "commands_changes": {} }, { "id": 482462, "type": "DiffNote", "body": "changed this file in [version 7 of the diff](...", "author": {...}, "created_at": "2025-10-27T13:23:57.320+01:00", "updated_at": "2025-10-27T13:23:57.320+01:00", "system": true, "noteable_id": 38062, "noteable_type": "MergeRequest", "project_id": 3336, "commit_id": null, "position": { "base_sha": "8017811eb76e7144a91f8e62daff8636f03e14d4", "start_sha": "8017811eb76e7144a91f8e62daff8636f03e14d4", "head_sha": "39ac4167acb2e01be9a0c4b50f0db2a3bd181939", "old_path": "src/ewoksutils/tests/cli_test_utils.py", "new_path": "src/ewoksutils/tests/cli_test_utils.py", "position_type": "file" }, "resolvable": false, "suggestions": [], "confidential": false, "internal": false, "imported": false, "imported_from": "none", "noteable_iid": 58, "commands_changes": {} } ] },This MR fixes the issue in these cases by
position.line_rangeis not defined