Skip to content

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

Merged
alexr00 merged 4 commits intomainfrom
copilot/fix-file-scoped-comment-error
Apr 16, 2026
Merged

Fix file-scoped comments failing with "Error: File has been deleted"#8664
alexr00 merged 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
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 <[email protected]>
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
@alexr00 alexr00 marked this pull request as ready for review April 16, 2026 09:59
Copilot AI review requested due to automatic review settings April 16, 2026 09:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes GitHub file-scoped PR review comments failing with Creating comment failed: Error: File has been deleted. by ensuring the GraphQL mutation doesn’t send an invalid line: 0 value when creating file-level threads.

Changes:

  • Update createReviewThread to pass endLine through directly (so line is omitted when endLine is undefined).
  • Update proposed VS Code chatSessionsProvider typings (type cleanup + new inputState surface).
Show a summary per file
File Description
src/github/pullRequestModel.ts Fixes GraphQL review thread creation for file-scoped comments by avoiding line: 0.
src/@types/vscode.proposed.chatSessionsProvider.d.ts Updates proposed API typings (removes legacy type union, adds/adjusts session input state-related types/docs).

Copilot's findings

  • Files reviewed: 1/2 changed files
  • Comments generated: 1

Comment thread src/github/pullRequestModel.ts
@alexr00 alexr00 merged commit 239b61a into main Apr 16, 2026
10 checks passed
@alexr00 alexr00 deleted the copilot/fix-file-scoped-comment-error branch April 16, 2026 14:34
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"

4 participants