Crash On Unrecognized CompletionItemKind

Aperta
#460 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
haskell
Ambito
api

Direzione di ricerca

La issue punta a lsp-types/src/Language/LSP/Types/Completion.hs e alla relativa dichiarazione A.FromJSON per CompletionItemKind. Inizia riproducendo il fallimento di decodifica di initialize riportato nel log allegato e traccia come vengono gestiti i valori di enumerazione sconosciuti. Il lavoro è completato quando una richiesta initialize contenente None o altri Completion Kinds sconosciuti non causa più un crash e questo caso è coperto dai test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I am attempting to build a language client against haskell-language-server in Visual Studio 2019.

When I follow the instructions for doing so however, haskell-language-server-wrapper fails with the following error

2022-09-24T11:34:34.192704Z | Info | Starting server
2022-09-24T11:34:34.193704Z | Error | Got error while decoding initialize:
Error in $.params.capabilities.textDocument.completion.completionItemKind.valueSet[0]: CompletionItemKind

Upon further investigation, it seems the issue is that in the CompletionItemKind enumeration defined in Microsoft.VisualStudio.LanguageServer.Protocol.dll, the first element of this enumeration is None. Visual Studio attempts to pass all members of this enumeration as supported completion kinds to the language server. In the A.FromJSON declaration, None is not a valid identifier, resulting in fail "CompletionItemKind" being called, which I believe is what leads to the exception above.

According to the LSP Specifiaction:

To support the evolution of enumerations the using side of an enumeration shouldn’t fail on an enumeration value it doesn’t know. It should simply ignore it as a value it can use and try to do its best to preserve the value on round trips. Lets look at the CompletionItemKind enumeration as an example again: if in a future version of the specification an additional completion item kind with the value n gets added and announced by a client a (older) server not knowing about the value should not fail but simply ignore the value as a usable item kind.

There are actually 13 "additional" values in the CompletionItemKind enum of Microsoft.VisualStudio.LanguageServer.Protocol.dll, so I believe the key issue here is that haskell/lsp (and by extension haskell-language-server) do not correctly ignore unknown enumeration values as recommended by the LSP specification. This may potentially affect other LSP enumeration kinds implemented by this project as well

Attached is the log output of haskell-language-server-wrapper that generated this error

log.log

Lingua principale
Haskell
Stelle
426
Fork
107
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di haskell/lsp

Tutte le issue di haskell/lsp

Issue simili

Altre issue su Haskell

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.