Skip to content

Do not crash if URI not parseable and no default handler exists#83024

Merged
dibarbet merged 1 commit intodotnet:mainfrom
dibarbet:dont_crash_missing_handler
Apr 2, 2026
Merged

Do not crash if URI not parseable and no default handler exists#83024
dibarbet merged 1 commit intodotnet:mainfrom
dibarbet:dont_crash_missing_handler

Conversation

@dibarbet
Copy link
Copy Markdown
Member

@dibarbet dibarbet commented Apr 2, 2026

Resolves dotnet/vscode-csharp#9130

This does not completely fix the errors, but it prevents the server from crashing. The root cause of the errors is an invalid URI (see dotnet/vscode-csharp#9087).

Scenario

When a request to the server is made for an unparsable URI and we have no saved language information sent to use via didOpen, the server falls back to trying to find a handler for the method using the default language.

However, some handlers have no default language handler, for example Razor's textDocument/documentColor handler. If we are unable to determine the language for a request for this method, the server would crash as it finds no default language handler.

Fix

The fix I made here is to not crash the server if we cannot find a handler for a request. The client still gets an error, but allows server operations to continue. This seemed appropriate as we do not control the client(s) and should not completely die if we get bad requests.

Microsoft Reviewers: Open in CodeFlow

@dibarbet dibarbet requested a review from a team as a code owner April 2, 2026 02:06
@dibarbet dibarbet merged commit fe9097b into dotnet:main Apr 2, 2026
27 checks passed
@dibarbet dibarbet deleted the dont_crash_missing_handler branch April 2, 2026 22:01
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server language crashed

2 participants