Skip to content

fix!: make lsp-server Response type closer aligned to JSON-RPC#22753

Open
ribru17 wants to merge 1 commit into
rust-lang:masterfrom
ribru17:response_typing
Open

fix!: make lsp-server Response type closer aligned to JSON-RPC#22753
ribru17 wants to merge 1 commit into
rust-lang:masterfrom
ribru17:response_typing

Conversation

@ribru17

@ribru17 ribru17 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

From the JSON-RPC 2.0 protocol:

result
This member is REQUIRED on success.
This member MUST NOT exist if there was an error invoking the method.
The value of this member is determined by the method invoked on the Server.
error
This member is REQUIRED on error.
This member MUST NOT exist if there was no error triggered during invocation.
The value for this member MUST be an Object as defined in section 5.1.

...

Either the result member or error member MUST be included, but both members MUST NOT be included.

The current typing of the Response object allows both the result and error members to be present, or for neither to be present. This commit strengthens the typing of the response to prevent these cases from being expressed. This is a breaking change.

The response kind definition is borrowed from the
tower-lsp definition.

From [the JSON-RPC 2.0 protocol](https://www.jsonrpc.org/specification#response_object):

> result
>  This member is REQUIRED on success.
>  This member MUST NOT exist if there was an error invoking the method.
>  The value of this member is determined by the method invoked on the Server.
> error
>  This member is REQUIRED on error.
>  This member MUST NOT exist if there was no error triggered during invocation.
>  The value for this member MUST be an Object as defined in section 5.1.
>
> ...
>
> Either the result member or error member MUST be included, but both members MUST NOT be included.

The current typing of the `Response` object allows both the `result` and
`error` members to be present, or for neither to be present. This commit
strengthens the typing of the response to prevent these cases from being
expressed. This is a breaking change.

The response kind definition is borrowed from the
[tower-lsp](https://github.com/ebkalderon/tower-lsp) definition.
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants