Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diagnostics are not displayed for invalid values, if there is an empty line before the variable. #1017

Open
aparnamichael opened this issue Oct 11, 2024 · 3 comments · Fixed by OpenLiberty/liberty-language-server#310
Assignees
Labels
bug Something isn't working
Milestone

Comments

@aparnamichael
Copy link
Contributor

aparnamichael commented Oct 11, 2024

Steps to reproduce:

  1. Add a variable "WLP_LOGGING_CONSOLE_FORMAT=DEV".
  2. Add an empty line (\n)
  3. Add another variable and assign an invalid value. "WLP_LOGGING_CONSOLE_LOGLEVEL=NONE"
  4. The diagnostic is not showing for the invalid value - "NONE"

LSP Traces:

  1. If there is an extra '\n' in "text" then 'textDocument/publishDiagnostics' is not showing in the Traces.
[Trace - 11:52:58] Sending notification 'textDocument/didChange'
Params: {
  "textDocument": {
    "version": 2,
    "uri": "file:///Users/aparnacmichael/Documents/test-projss/app-name-test-one/src/main/liberty/config/server.env"
  },
  "contentChanges": [
    {
      "text": "WLP_LOGGING_CONSOLE_FORMAT\u003dDEV\n\nWLP_LOGGING_CONSOLE_LOGLEVEL\u003dNONE"
    }
  ]
}
  1. In this scenario there is no '\n' or empty line in between the variables and 'textDocument/publishDiagnostics' is present in the traces.
[Trace - 11:48:41] Sending notification 'textDocument/didChange'
Params: {
  "textDocument": {
    "version": 2,
    "uri": "file:///Users/aparnacmichael/Documents/test-projss/app-name-test-one/src/main/liberty/config/server.env"
  },
  "contentChanges": [
    {
      "text": "WLP_LOGGING_CONSOLE_FORMAT\u003dDEV\nWLP_LOGGING_CONSOLE_LOGLEVEL\u003dNONE"
    }
  ]
}


[Trace - 11:48:41] Received notification 'textDocument/publishDiagnostics'
Params: {
  "uri": "file:///Users/aparnacmichael/Documents/test-projss/app-name-test-one/src/main/liberty/config/server.env",
  "diagnostics": [
    {
      "range": {
        "start": {
          "line": 1,
          "character": 29
        },
        "end": {
          "line": 1,
          "character": 33
        }
      },
      "severity": 1,
      "source": "Liberty Config Language Server",
      "message": "The value `NONE` is not valid for the variable `WLP_LOGGING_CONSOLE_LOGLEVEL`."
    }
  ]
}

serverenv-traces.mov

vs code behaviour is a little different but similar issue is present in vs code as well -OpenLiberty/liberty-tools-vscode#343

@aparnamichael aparnamichael added the bug Something isn't working label Oct 11, 2024
@aparnamichael aparnamichael added this to the Next milestone Oct 11, 2024
@angelozerr
Copy link

It is a problem with your language server and not from LSP4IJ. You should have the same problem with vscode.

@arunvenmany-ibm arunvenmany-ibm self-assigned this Oct 11, 2024
@arunvenmany-ibm
Copy link

Hi @cherylking

I found the issue is due to blank line not having any property and causing NPE.
Is it okay to ignore the blank line and just scan the next line ?
Is there any requirement to show diagnostics on blank line?
I made some code changes for skipping blank line and its working fine now

image

@cherylking
Copy link
Member

@arunvenmany-ibm According to this documentation, empty lines should be ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

4 participants