Skip to content

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

Draft
Copilot wants to merge 3 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 3 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
  • src/test/view/reviewCommentController.test.ts: Add test for file-scoped comment creation verifying line: undefined and subjectType: 'FILE' in the mutation

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
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