node-gitlab-2-github
node-gitlab-2-github copied to clipboard
handle undefined position.line_range in case of comments on empty files
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
- modifying the slug to point to the file in the compare (not a line in the file, because it is an empty file)
- not adding the line-range link when
position.line_rangeis not defined