Repository: vscode
Issue: LSP Code Action Requests with wrong types are sent
Labels: help wanted,feature-request,editor-code-actions

<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ -->
<!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ -->
<!-- 🕮 Read our guide about submitting issues: https://github.com/microsoft/vscode/wiki/Submitting-Bugs-and-Suggestions -->
<!-- 🔎 Search existing issues to avoid creating duplicates. -->
<!-- 🧪 Test using the latest Insiders build to see if your issue has already been fixed: https://code.visualstudio.com/insiders/ -->
<!-- 💡 Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. -->
If VSCode somehow obtains faulty diagnostics, it also sends them – out of spec – to other LSP-servers in Code Action Requests. More specifically, it sends the position:

```json
"start": {
    "line": null,
    "character": 0
},
```

To my understanding, the line has to be `uinteger` but not `null`. This results in failing LSP servers.

This specific issue might be fixed at the source of the faulty diagnostic. I have therefore created an [issue](https://github.com/James-Yu/LaTeX-Workshop/issues/3774) in the LaTeX-Workshop extension. It turns out though, that they don’t use an LSP server, but the npm vscode module which requires the line to be of type `number` which allows for value `NaN`. Moreover, I think that VSCode should not send faulty LSP messages. For the case of diagnostics, it should either filter such diagnostics, which do not adhere to the LSP, or directly block them, when they are given to VSCode in the first place.

<!-- 🔧 Launch with `code --disable-extensions` to check. -->
Does this issue occur when all extensions are disabled?: (probably) No

<!-- 🪓 If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. -->
<!-- 📣 Issues caused by an extension need to be reported directly to the extension publisher. The 'Help > Report Issue' dialog can assist with this. -->
- VS Code Version: Version: 1.76.1, Release: 23069, (actually using VSCodium)
- OS Version: macOS 13.2.1 / Darwin x64 22.3.0  (also happens on Windows)

Steps to Reproduce:

What I describe here, is how I noticed this error. I expect, that it can also appear in a lot of other contexts.

1. Install the [LaTeX Workshop extension](https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop).
2. Install any other LSP server which works in LaTeX documents and allows for Code Action Requests (I experience this with the still unpublished [YaLafi-LS-VScode extension](https://github.com/torik42/YaLafi-LS-VScode) and will update this issue, as soon as a first version is published. The server itself is available [here](https://github.com/torik42/YaLafi-LS).)
3. Open the following LaTeX file and build with xelatex.
    ```latex
    \documentclass{article}
    
    \usepackage{mathtools}
    \usepackage{unicode-math}
    
    \begin{document}
        This is some text.
    \end{document}
    ```
    This will issue two warnings with the faulty positions, they are displayed at the beginning of the file.
4. Move around in the document. VSCode will send faulty Code Action Requests to the LSP server looking like this.
    ```json
    {
        "jsonrpc": "2.0",
        "id": 10,
        "method": "textDocument/codeAction",
        "params":{
            "textDocument":{
                "uri": "file:///.../test.tex"
            },
            "range":{
                "start":{
                    "line": 7,
                    "character": 14
                },
                "end":{
                    "line": 7,
                    "character": 14
                }
            },
            "context":{
                "diagnostics":[
                    {
                        "range":{
                            "start":{
                                "line": null,
                                "character": 0
                            },
                            "end":{
                                "line": null,
                                "character": 65535
                            }
                        },
                        "message": "Using \\overbracket and \\underbracket from\n(unicode-math)\t`mathtools' package.\n(unicode-math)\t\n(unicode-math)\tUse \\Uoverbracket and \\Uunderbracket for\n(unicode-math)\toriginal `unicode-math' definition.\n",
                        "severity": 2,
                        "source": "LaTeX"
                    },
                    {
                        "range":{
                            "start":{
                                "line": null,
                                "character": 0
                            },
                            "end":{
                                "line": null,
                                "character": 65535
                            }
                        },
                        "message": "I'm going to overwrite the following commands\n(unicode-math)\tfrom the `mathtools' package: \n(unicode-math)\t\n(unicode-math)\t\\dblcolon, \\coloneqq, \\Coloneqq, \\eqqcolon.\n(unicode-math)\t\n(unicode-math)\t\n(unicode-math)\tNote that since I won't overwrite the other\n(unicode-math)\tcolon-like commands, using them will lead to\n(unicode-math)\tinconsistencies.\n",
                        "severity": 2,
                        "source": "LaTeX"
                    }
                ]
            }
        }
    }
    ```
5. In my specific case with the server implemented using [pygls](https://github.com/openlawlibrary/pygls) I get the attached log [test-pygls.log](https://github.com/microsoft/vscode/files/10969496/test-pygls.log).

**Edit:** Added link and short comment about issue in LaTeX Workshop extension.