-
Notifications
You must be signed in to change notification settings - Fork 94
Spec compliance: null vs missing values #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Note: wow, I am slightly sleep deprived and didn't notice that I already filed an issue for this back in May (#246). I think this one is the better write-up so I'll close the other one :) |
I wonder if there's any existing package that offers "another Maybe". |
We already do something similar for the |
Closed by |
I just noticed that some types don't perfectly obey the LSP spec regarding when a value is allowed to be missing vs. when it must be present and
null
.For example, if you look at InitializeParams, the
processId
field has typeprocessId: integer | null
, while thelocale
field is writtenlocale?: string
. Thus the latter is allowed to be missing but the former is not.All optional fields in this package seem to be represented as
Maybe
, and encoded to JSON withomitNothingFields = True
:https://github.com/alanz/lsp/blob/36b655d9cc538f79b14c847ca383d97ffcc18162/lsp-types/src/Language/LSP/Types/Utils.hs#L109
https://github.com/alanz/lsp/blob/36b655d9cc538f79b14c847ca383d97ffcc18162/lsp-types/src/Language/LSP/Types/Initialize.hs#L44
This caused a problem for me when trying to write a Haskell client for a Python language server powered by pygls. Upon sending an
initialize
message with an emptyprocessId
, I get an NPE because it assumes the value will be present:To be compliant with the spec, perhaps we need to replace these "required optional values" with a different
Maybe
-like wrapper that always encodes tonull
when empty?The text was updated successfully, but these errors were encountered: