microsoft/vscode-languageserver-node

VS Code diagnostics with position: Number.MAX_VALUE (2^1024) are passed to the LSP server (which only allows 2^32)

DanTup opened this issue · 0 comments

I'm not really sure if this will be considered a bug, but an issue came up where the Dart LSP server was rejecting some codeAction requests unexpectedly. It turned out this only occurred with a specific extension installed and it caused the request to look like this:

{
	"jsonrpc": "2.0",
	"id": 134,
	"method": "textDocument/codeAction",
	"params": {
		"textDocument": {
			"uri": "file:///Users/wn/Works/study/code_action_bug_handler/lib/main.dart"
		},
		"range": {
			"start": {
				"line": 3,
				"character": 2
			},
			"end": {
				"line": 3,
				"character": 1.7976931348623157e+308
			}
		},
		"context": {
			"diagnostics": [
				{
					"range": {
						"start": {
							"line": 3,
							"character": 0
						},
						"end": {
							"line": 3,
							"character": 1.7976931348623157e+308
						}
					},
					"message": "[code-coverage] line not covered",
					"severity": 3
				}
			],
			"only": [
				"quickfix"
			]
		}
	}
}

The character value here is Number.MAX_VALUE (2^1024) and is being set here:

https://github.com/markis/vscode-code-coverage/blob/bb8cdae9cb243f1514da7af2e9960f3fa87ccd56/src/extension.ts#L160

As far as I can tell, this is valid according to the VS Code API (even though it seems slightly unnecessary). However LSP defines this field as uinteger capped at 2^32.

If this value is valid to VS Code, but not for LSP, it seems like this LSP client should be handling that, rather than passing the invalid data on to servers (which they may reject as not confirming).