redhat-developer / redhat-developer/lsp4ij
`null` gets stripped from user-defined language server configurations
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 344
- Forks
- 113
- Avg merge
- 5h 22m
- Merged PRs (30d)
- 15
Description
I'm setting configurations through the user-defined language server UI, and find that properties with values explicitly set as null are being stripped before the server receives them:
[Trace - 15:45:59] Sending request 'initialize - (1)'.
Params: {
<...>,
"initializationOptions": {
"field2": "name",
"field3": "nullaaaa"
},
[Trace - 15:50:03] Sending notification 'workspace/didChangeConfiguration'
Params: {
"settings": {
"fieldB": "name"
}
}
When I use the server to request the options/settings from the client, the fields which were set to null are now simply missing.
I expect preservation of fields set to null when sent from the client to the server1. The configuration object that's being retrieved from the UI2 shows that null is actually present in the client configuration object before being sent to the server, so something must be happening after reading the configuration.
-
According to the language server specification, the types of
initializationOptionsand return value of configuration requests are bothLSPAny, which is a type union includingLSPObjectandnull.LSPObjectis defined as:type LSPObject = { [key: string]: LSPAny };So,
LSPObjects are allowed to havestringkeys andnullvalues. -
Using the following modification of
com.redhat.devtools.lsp4ij.server.definition.launching.UserDefinedLanguageServerDefinition:... + import com.google.gson.JsonElement; import com.google.gson.JsonParser; ... public Object getLanguageServerConfiguration() { if (configuration == null && configurationContent != null && !configurationContent.isBlank()) { try { configuration = JsonParser.parseReader(new StringReader(configurationContent)); } catch (Exception e) { LOGGER.error("Error while parsing JSON configuration for the language server '" + getId() + "'", e); } } + LOGGER.error("CONFIGURATION IS: " + ((JsonElement)configuration).toString()); return configuration; }IDE Logs:
SEVERE - com.redhat.devtools.lsp4ij.server.definition.launching.UserDefinedLanguageServerDefinition - CONFIGURATION IS: {"fieldA":null,"fieldB":"name"}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with UserDefinedLanguageServerDefinition.java and trace how its parsed configuration is passed into initializationOptions and workspace configuration responses. Reproduce the case using a configuration containing a null value, then verify that the value remains present in both messages sent to the language server.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100