Skip to content

Noisy error on textDocument/hover ("position outside of [...] body") #1922

Open
@krobelus

Description

@krobelus

Language Server Version

0.36.3

Terraform Version

v1.10.2

Client Version

Kakoune

Terraform Configuration

terraform {
}

Steps to Reproduce

Reproduced in Kakoune (with kakoune-lsp) but should be reproducible in any editor

  1. open the above file, move the cursor the opening brace
  2. run textDocument/hover (:lsp-hover in Kakoune)

Expected Behavior

no error should be shown, the response should be {"jsonrpc":"2.0","id":213,"result":null}
since there is nothing interesting at the cursor position

Actual Behavior

observe that the error 'test.tf (1,11): position outside of "terraform" body' is prominently shown
terraform-ls returns {"jsonrpc":"2.0","id":8,"error":{"code":-32098,"message":"test.tf (1,11): position outside of \"terraform\" body"}}
which is rightfully shown as error because that's what it is.

Here's a slice of logs from the *debug* buffer:

LSP: DEBG To server terraform-ls: {"jsonrpc":"2.0","method":"textDocument/hover","params":{"position":{"character":10,"line":0},"textDocument":{"uri":"file:///home/johannes/git/kakoune-lsp/t/test.tf"}},"id":8}
LSP: INFO Language server stderr: 2025/01/09 09:51:20 opts.go:215: Received request batch of size 1 (qlen=0)
LSP: INFO Language server stderr: 2025/01/09 09:51:20 opts.go:215: Dequeued request batch of length 1 (qlen=0)
LSP: INFO Language server stderr: 2025/01/09 09:51:20 rpc_logger.go:32: Incoming request for "textDocument/hover" (ID 8): {"position":{"character":10,"line":0},"textDocument":{"uri":"file:///home/johannes/git/kakoune-lsp/t/test.tf"}}
LSP: INFO Language server stderr: 2025/01/09 09:51:20 hover.go:41: Looking for hover data at "test.tf" -> hcl.Pos{Line:1, Column:11, Byte:10}
LSP: INFO Language server stderr: 2025/01/09 09:51:20 hover.go:43: received hover data: (*lang.HoverData)(nil)
LSP: INFO Language server stderr: 2025/01/09 09:51:20 rpc_logger.go:48: Error for "textDocument/hover" (ID 8): [-32098] test.tf (1,11): position outside of "terraform" body
LSP: INFO Language server stderr: 2025/01/09 09:51:20 opts.go:215: Completed 1 requests [883.584µs elapsed]
LSP: DEBG From server terraform-ls: {"jsonrpc":"2.0","id":8,"error":{"code":-32098,"message":"test.tf (1,11): position outside of \"terraform\" body"}}
LSP: ERRO Error response from server terraform-ls: Failure { jsonrpc: Some(V2), error: Error { code: ServerError(-32098), message: "test.tf (1,11): position outside of \"terraform\" body", data: None }, id: Num(8) }
LSP: ERRO language server terraform-ls error: 'test.tf (1,11): position outside of "terraform" body'

Gist

No response

Workarounds

No response

References

No response

Help Wanted

  • I'm interested in contributing a fix myself

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions