LspError.data missing #[serde(default)] swallows the real jdtls error

Open Beginner friendly
#325 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
json, rust
Domain
backend

Research direction

The struct LspError is defined in src/lsp.rs and the untagged LspResponse enum that wraps it is where parsing fails. Start by reading those two definitions, then add #[serde(default)] to the data field. To verify, send a proxy response with an error object that has no data key and confirm the message field reaches the user unchanged.

Written by the indexing model from the issue text.

Description

Summary

src/lsp.rs defines

pub struct LspError {
    code: i64,
    message: String,
    data: Value,   // no #[serde(default)]
}

LSP allows error.data to be omitted. When jdtls returns an error without data, the Error variant fails to deserialize, and since LspResponse is an untagged enum, the whole parse fails with:

Failed to parse response from LSP proxy: data did not match any variant of untagged enum LspResponse

Impact

The actual error message is swallowed. In our case the real response was:

{"error":{"code":-32601,"message":"No delegateCommandHandler for vscode.java.resolveMainClass"},"id":"...","jsonrpc":"2.0"}

but Zed surfaced the misleading serde error, which pointed everyone (including maintainers reading our report) at "protocol/proxy problems" instead of the broken debug plugin (see #324). This cost a long debugging session.

Repro

  • Start a debug session while the java-debug bundle is broken/unloaded (e.g. #324)
  • Or directly: curl -X POST http://127.0.0.1:<proxy-port>/ -d '{"method":"workspace/executeCommand","params":{"command":"vscode.java.resolveMainClass","arguments":[]}}' — the response error has no data field

Fix

Add #[serde(default)] to data (one-liner) so the real message (No delegateCommandHandler ...) reaches the user.

Dominant language
Rust
Stars
225
Forks
47
Avg merge
3h 51m
Merged PRs (30d)
7

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from zed-extensions/java

All issues in zed-extensions/java

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.