pyrefly icon indicating copy to clipboard operation
pyrefly copied to clipboard

Missing Field Postion in request "textDocument/definition"

Open WayenVan opened this issue 1 year ago • 5 comments

Describe the Bug

When using lsp server in neovim 11.2, the lsp request seems not handle proply

[ERROR][2025-07-27 16:07:14] ...p/_transport.lua:36	"rpc"	"pyrefly"	"stderr"	'ERROR Thread panicked, shutting down: panicked at pyrefly/lib/lsp/server.rs:1870:13:\nInvalid request\n  method: textDocument/definition\n  error: missing field `position`\n  request: Request { id: RequestId(I32(3)), method: "textDocument/definition", params: Object {"textDocument": Object {"uri": String("file:///home/jingyan/Desktop/python-test/a.py")}} }\n\nBacktrace:\n   0: <unknown>\n   1: <unknown>\n   2: <unknown>\n   3: <unknown>\n   4: <unknown>\n   5: <unknown>\n   6: <unknown>\n   7: <unknown>\n   8: <unknown>\n   9: <unknown>\n  10: <unknown>\n  11: <unknown>\n  12: <unknown>\n  13: <unknown>\n  14: <unknown>\n  15: <unknown>\n  16: __libc_start_call_main\n             at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\n  17: __libc_start_main_impl\n             at ./csu/../csu/libc-start.c:360:3\n  18: <unknown>\n\nPANIC Sorry, Pyrefly crashed, this is always a bug in Pyrefly itself.\nPANIC Please report the bug at https://github.com/facebook/pyrefly/issues/new\n'

This error occur whenever the lsp start And could be temporarily fix by disable the definitionProvider capaility

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

neovim v0.11.1 pyrefly v-.25.1

WayenVan avatar Jul 27 '25 15:07 WayenVan

Thanks for the report! The textDocument/definition request does require a position field, so it's curious that neovim did not send one. That said, we certainly should not panic when this happens!

samwgoldman avatar Jul 27 '25 20:07 samwgoldman

@connernilsen have you seen this before (you use neovim)? I think the actual fix for this would be to get neovim to send a position. Without position, how will we know where to resolve the definition from?

kinto0 avatar Jul 29 '25 19:07 kinto0

I was having the same problem with other LSPs too, and I figured out it was caused by dropbar.nvim. Going back to an older version fixed it for me.

jundenilson avatar Jul 29 '25 21:07 jundenilson

Thank you, I can confirm that the drop bar has sent the wrong lsp request maybe we need an issue there.

WayenVan avatar Jul 29 '25 23:07 WayenVan

after 87fa90821f40ff736c6430658d8102f9737d924a, we will no longer panic if this happens. instead we will respond with an Error via LSP so the other requests still work

kinto0 avatar Jul 30 '25 18:07 kinto0