Repository navigation
Description
Summary
textDocument/definition failures can be reported to users as textDocument/declaration failures. This makes it look like the client sent a declaration request even when the JSON-RPC traffic shows that the actual request was textDocument/definition.
I opened a small fix in #1485.
What I observed
While debugging Nix language server integration with nixd, the IDE showed this error:
Error while consuming 'textDocument/declaration' with language server 'nixd'
org.eclipse.lsp4j.jsonrpc.ResponseErrorException: unknown node type for definition
However, LSP traffic logging showed that the IDE was sending textDocument/definition, not textDocument/declaration:
{"jsonrpc":"2.0","id":"14","method":"textDocument/definition","params":{"textDocument":{"uri":"file:///.../devshell.nix"},"position":{"line":3,"character":12}}}The language server then returned an error for that same definition request:
{"error":{"code":-32001,"message":"unknown node type for definition"},"id":"14","jsonrpc":"2.0"}Root cause
LSPDefinitionSupport#getDefinitionFor calls TextDocumentService.definition(params), but passes LSPRequestConstants.TEXT_DOCUMENT_DECLARATION into CancellationSupport.execute(...).
That means CancellationSupport logs/reports definition request failures using the declaration request name.
Current code:
return cancellationSupport.execute(languageServer
.getTextDocumentService()
.definition(params), languageServer, LSPRequestConstants.TEXT_DOCUMENT_DECLARATION)
.thenApplyAsync(locations -> LSPIJUtils.getLocations(locations, languageServer));Expected code:
return cancellationSupport.execute(languageServer
.getTextDocumentService()
.definition(params), languageServer, LSPRequestConstants.TEXT_DOCUMENT_DEFINITION)
.thenApplyAsync(locations -> LSPIJUtils.getLocations(locations, languageServer));Impact
Users and plugin authors may chase declaration capability issues when the failing request is actually definition. In my case, nixd did not advertise declarationProvider, so the reported method made the diagnosis misleading until raw LSP traffic was inspected.
This may also explain reports like #1434 where the visible error mentions textDocument/declaration.
Verification
For #1485 I verified the patch with:
./gradlew compileJava
Activity
bodiam commentedon May 9, 2026
Hi @angelozerr, apologies for creating this AI PRs, but this is an issue I encountered while developing an IntelliJ plugin. I've tested it, and the PR fixes the issue. I tried creating a test for it, but the test is quite nasty, I don't think you'd appreciate it much.
angelozerr commentedon May 9, 2026
Thanks @bodiam ! I merged your PR. When https://github.com/redhat-developer/lsp4ij/actions/runs/25597066966 will be finished (soon) you will able to install nighty build
angelozerr commentedon May 9, 2026
Fixed with #1485
angelozerr commentedon May 9, 2026
Where is your plugin?
bodiam commentedon May 10, 2026
Thanks for merging this!
I had published the plugin, but then I found a few issues (this being one of them), so I had to remove the plugin and fix those issues. I'm currently going through a few open source Nix projects to validate the plugin and fix another few issues I found while doing it, so I expect the plugin to be available this week.