Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes error handling for invalid JSON-RPC request parameters in the LSP server. Previously, when parameter unmarshaling failed, the server was using the generic InvalidRequest error code and wasn't properly preserving the request ID in the error response, which could cause issues like the fuzzer hanging.
Changes:
- Changed error code from
InvalidRequestto the more specificInvalidParamswhen parameter unmarshaling fails - Modified error handling to preserve and return the request ID in error responses for invalid params
- Added test coverage to verify the fix works correctly
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| internal/lsp/lsproto/jsonrpc.go | Moved error check after Message construction to allow ID extraction, changed error code to InvalidParams |
| internal/lsp/server.go | Added logic to detect InvalidParams errors and extract request ID from the partially unmarshaled message for error responses |
| internal/lsp/server_invalid_message_test.go | Added test to verify that invalid params trigger the correct error code and response includes the request ID |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
jakebailey
reviewed
Feb 11, 2026
jakebailey
reviewed
Feb 11, 2026
added 4 commits
February 12, 2026 00:12
gabritto
commented
Feb 12, 2026
gabritto
commented
Feb 12, 2026
| type ResponseMessage struct { | ||
| JSONRPC jsonrpc.JSONRPCVersion `json:"jsonrpc"` | ||
| ID *jsonrpc.ID `json:"id,omitzero"` | ||
| ID *jsonrpc.ID `json:"id"` |
Member
Author
There was a problem hiding this comment.
Per the spec, if we fail to decode a request or notification (i.e. the whole thing, not just params), we are allowed to return an error response with null id.
jakebailey
reviewed
Feb 12, 2026
jakebailey
approved these changes
Feb 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found this while testing the fuzzer: if we failed to unmarshal params for a request, we weren't really sending the error message with the proper id (this was causing the fuzzer to hang). We were also using error code invalid request even when we should the more specific invalid params error.