Skip to content

Fix Watson crash in ToRazorTextDocumentIdentifier when DocumentUri is unparseable#13043

Merged
ToddGrun merged 2 commits intomainfrom
dev/toddgrun/2900155
Apr 13, 2026
Merged

Fix Watson crash in ToRazorTextDocumentIdentifier when DocumentUri is unparseable#13043
ToddGrun merged 2 commits intomainfrom
dev/toddgrun/2900155

Conversation

@ToddGrun
Copy link
Copy Markdown
Contributor

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2900155

DocumentUri.ParsedUri can be null when System.Uri cannot parse the URI string received from the client (e.g. unusual URI schemes in VS Code). RazorDocumentClosedEndpoint.GetRazorTextDocumentIdentifier called GetRequiredParsedUri() which threw InvalidOperationException via AssumeNotNull.

Changes:

  • ToRazorTextDocumentIdentifier now returns null when ParsedUri is null instead of throwing
  • RazorDocumentClosedEndpoint.HandleRequestAsync guards the DocumentRemoved call, skipping it when ParsedUri is null. This is safe because HtmlDocumentSynchronizer only tracks documents opened with valid URIs via TrySynchronizeAsync.
  • CohostSignatureHelpEndpoint now uses ToRazorTextDocumentIdentifier instead of inlining the same logic with GetRequiredParsedUri

… unparseable

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2900155

    DocumentUri.ParsedUri can be null when System.Uri cannot parse the URI string received from the client (e.g. unusual URI schemes in VS Code). RazorDocumentClosedEndpoint.GetRazorTextDocumentIdentifier called GetRequiredParsedUri() which threw InvalidOperationException via AssumeNotNull(), causing Watson crash 2900155.

Changes:
 - ToRazorTextDocumentIdentifier now returns null when ParsedUri is null instead of throwing
 - RazorDocumentClosedEndpoint.HandleRequestAsync guards the DocumentRemoved call, skipping it when ParsedUri is null. This is safe because HtmlDocumentSynchronizer only tracks documents opened with valid URIs via TrySynchronizeAsync.
 - CohostSignatureHelpEndpoint now uses ToRazorTextDocumentIdentifier instead of hand-inlining the same logic with GetRequiredParsedUri
@ToddGrun ToddGrun requested a review from a team as a code owner April 13, 2026 17:58
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.

2 participants