Skip to content

Fix file-scoped comments failing with "Error: File has been deleted"#8664

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/fix-file-scoped-comment-error
Draft

Fix file-scoped comments failing with "Error: File has been deleted"#8664
Copilot wants to merge 4 commits intomainfrom
copilot/fix-file-scoped-comment-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

File-scoped comments (via the comment button at the top of a file tab) fail with Creating comment failed: Error: File has been deleted. on modified files.

Cause

In createReviewThread, when endLine is undefined (file-scoped comment), the GraphQL mutation variable was set to line: 0:

line: (endLine === undefined) ? 0 : endLine,

The GitHub API rejects line: 0 and returns a null thread, which hits the null-check that throws the misleading "File has been deleted" error. The line parameter is not required when subjectType is FILE.

Fix

  • src/github/pullRequestModel.ts: Pass endLine directly instead of converting undefined to 0

Copilot AI and others added 2 commits April 14, 2026 10:05
Agent-Logs-Url: https://github.com/microsoft/vscode-pull-request-github/sessions/2e5f5355-cccd-4ac6-b866-9d00dcd8b8b4

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
When creating a file-scoped comment (range is undefined), the
createReviewThread method was passing `line: 0` to the GitHub GraphQL
API. The API does not accept line 0 and returns a null thread, which
caused the misleading "File has been deleted" error.

Fix: pass endLine directly (undefined for file-scoped comments) instead
of converting undefined to 0. The line parameter is not required when
subjectType is FILE.

Agent-Logs-Url: https://github.com/microsoft/vscode-pull-request-github/sessions/2e5f5355-cccd-4ac6-b866-9d00dcd8b8b4

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix bug with file-scoped comment submission Fix file-scoped comments failing with "Error: File has been deleted" Apr 14, 2026
Copilot AI requested a review from alexr00 April 14, 2026 10:09
Copy link
Copy Markdown
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot, I think that test just tests the mocks. Remove the test.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 15, 2026

@copilot, I think that test just tests the mocks. Remove the test.

Removed the test in a17b37d.

Copilot AI requested a review from alexr00 April 15, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File-Scoped Comment Fails with "Error: File has been deleted"

2 participants