Open ebkalderon opened 1 year ago
I've opened https://github.com/gluon-lang/lsp-types/pull/259 to correct this at the lsp-types
level.
This issue was previously touched on in PR #379. Most of the code in improve-jsonrpc-deserialization
that hasn't yet been integrated into mainline covers a big portion of this work already.
According to both the JSON-RPC 2.0 specification and the Language Server Protocol specification, the
params
field in all JSON-RPC requests and notifications must be either:At the time of writing,
tower-lsp
'sRequest
type does not reject messages withparams
fields that are not either object-like or array-like. This was done to accommodate thetelemetry/event
notification which, until recently, erroneously mandated aparams
type ofobject | number | boolean | string
. Thankfully, this was corrected in the spec: https://github.com/microsoft/language-server-protocol/issues/1686We already restrict users from emitting non-object and non-array
telemetry/event
payloads inclient.rs
, so there's no additional work necessary on that front.https://github.com/ebkalderon/tower-lsp/blob/e96d8ca822e63218dab8bae8825a7f8a4537fea0/src/service/client.rs#L203-L211
However, we should still update the
Request
type andLspServiceBuilder::custom_method()
to rejectparams
values that are not serializable/deserializable to and from objects/arrays in order to fully comply.