Skip to content

fix: the LSP console's traces show a message of a language server that LSP4J can't parse, which only the IDE log had - #2213

Closed
lagergren wants to merge 1 commit into
redhat-developer:mainfrom
lagergren:fix/lsp-console-traces-unparsable-messages
Closed

lagergren wants to merge 1 commit into
redhat-developer:mainfrom
lagergren:fix/lsp-console-traces-unparsable-messages

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Part of #584 (its part 2). Part 1 isn't LSP4IJ's: the server sends 4294967295, above LSP's maximum integer.

What

A message from a language server that LSP4J can't parse, such as a publishDiagnostics whose character is 4294967295, went only to the IDE log, through RemoteEndpoint.handle → logIssues. The LSP console's traces didn't show it, even with tracing on, so the message seemed never to have arrived.

Change

  • DefaultLauncherBuilder.create() gives the message producer an issue handler of its own. It traces the message first, as parsed messages are traced (through LanguageServerWrapper.logMessageIssues and the lifecycle manager), then calls remoteEndpoint.handle(message, issues) as before, so LSP4J still answers or logs it.

  • LSPTrace gets an issues component, and its earlier constructor stays. TracingMessageConsumer.logIssues writes the trace:

    • for a notification, its method and the issue;
    • for a request, its method, and LSP4J's error response shows that method;
    • for a response, the method and latency of its request.

    At the verbose level, the trace also shows the params or result that LSP4J kept.

For example:

[Trace - 17:28:28] Received notification 'textDocument/publishDiagnostics' that could not be parsed.
Issue: Message could not be parsed. java.lang.NumberFormatException: Expected an int but was 4294967295 at line 1 column 199 path $.params.diagnostics[0].range.end.character

Not in this PR:

  • The raw text of the message: LSP4J parses straight from the stream, so it's gone by the time the issue handler runs. The issue names the path and the value.
  • A launcher builder that doesn't extend DefaultLauncherBuilder doesn't get this.

The lifecycle listeners now also get handleLSPMessage for an unparsable message; the console needs it to refresh its traces.

Tests

  • New LSPConsoleUnparsableMessageTraceTest: the mock server sends that publishDiagnostics as raw JSON, then a window/logMessage. The console's traces show both, in order, and the server stays started.
  • Two new cases in TracingMessageConsumerTest: an unparsable request and an unparsable response.
  • Red-green: without the DefaultLauncherBuilder hook, the traces show the window/logMessage but not the publishDiagnostics. With it, the test passes.
  • Headless on IC 2024.2, 2025.3 and IU 2026.3: 8 tests, 0 failures, 0 skipped.
  • console.*, server.* and CancelRequestAfterShutdownTest on all three platforms: 187 tests each, 0 failures. The 4 skipped tests are the existing Windows-only CommandUtilsTest cases.

Behaviour change

Before After
A message that LSP4J can't parse appears only in the IDE log It also appears in the LSP console's traces, with the issue and the field that failed; LSP4J handles it as before

…t LSP4J can't parse, which only the IDE log had

LSP4J hands a message that it can't parse, as a notification whose params
don't fit their type, to its issue handler, which DefaultLauncherBuilder set
to the remote endpoint, instead of to the message consumer that traces the
messages. Such a message therefore never showed in the traces of the LSP
console: a textDocument/publishDiagnostics notification with a character
above the maximum integer of LSP showed nowhere but in the IDE log.

The issue handler now traces the message first, as received, with the issues
that LSP4J found in it, as "Message could not be parsed.
java.lang.NumberFormatException: Expected an int but was 4294967295 at line 1
column 199 path $.params.diagnostics[0].range.end.character", and the params
or result that LSP4J kept, at the verbose level. It then lets the remote
endpoint handle the message as before. The trace of a request that can't be
parsed lets the error response that LSP4J sends to it show its method, and
the trace of a response that can't be parsed shows the method and the latency
of its request.

Part of redhat-developer#584
@lagergren lagergren added this to the 0.30.2 milestone Nov 24, 2026
@lagergren lagergren added the bug Something isn't working label Nov 24, 2026
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

This review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry.

Next included review available in 17 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 389bdf5e-6416-4bed-98a5-3eefaee651ed
Commits

Reviewing files that changed from the base of the PR and between d592c89 and c821e20.

Files selected for processing: 6

  • src/main/java/com/redhat/devtools/lsp4ij/LanguageServerWrapper.java
  • src/main/java/com/redhat/devtools/lsp4ij/console/explorer/TracingMessageConsumer.java
  • src/main/java/com/redhat/devtools/lsp4ij/lifecycle/LanguageServerLifecycleManager.java
  • src/main/java/com/redhat/devtools/lsp4ij/server/DefaultLauncherBuilder.java
  • src/test/java/com/redhat/devtools/lsp4ij/console/LSPConsoleUnparsableMessageTraceTest.java
  • src/test/java/com/redhat/devtools/lsp4ij/console/explorer/TracingMessageConsumerTest.java

@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.81132% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.63%. Comparing base (1b0b053) to head (c821e20).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...sp4ij/console/explorer/TracingMessageConsumer.java 78.12% 3 Missing and 4 partials ⚠️
.../redhat/devtools/lsp4ij/LanguageServerWrapper.java 45.45% 5 Missing and 1 partial ⚠️
...devtools/lsp4ij/server/DefaultLauncherBuilder.java 71.42% 1 Missing and 1 partial ⚠️
...p4ij/lifecycle/LanguageServerLifecycleManager.java 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2213      +/-   ##
==========================================
+ Coverage   54.59%   54.63%   +0.03%     
==========================================
  Files         834      834              
  Lines       35385    35434      +49     
  Branches     7300     5554    -1746     
==========================================
+ Hits        19320    19359      +39     
- Misses      13223    13230       +7     
- Partials     2842     2845       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lagergren

Copy link
Copy Markdown
Collaborator Author

Combined, unchanged, with the other small fixes into #2219, one commit each, so that they take one review instead of six.

@lagergren lagergren closed this Nov 24, 2026
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

None yet

Development

Successfully merging this pull request may close these issues.

1 participant