Skip to content

fix(lsp): handle mcpls object-wrapped diagnostics response#3594

Merged
bug-ops merged 2 commits intomainfrom
3593-lsp-diagnostics-parse
May 5, 2026
Merged

fix(lsp): handle mcpls object-wrapped diagnostics response#3594
bug-ops merged 2 commits intomainfrom
3593-lsp-diagnostics-parse

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented May 5, 2026

Summary

  • fetch_diagnostics in zeph-core/src/lsp_hooks/diagnostics.rs silently returned None on every call because it expected a bare JSON array from mcpls get_diagnostics, but mcpls v0.3.6+ returns {"diagnostics": [...]} (a DiagnosticsResult struct)
  • Added parse_diagnostics_json() helper that handles both the legacy bare-array format and the object-wrapper format
  • Added 5 tests: 1 integration-style regression test + 4 unit tests for edge cases (bare array, empty wrapper, missing key, invalid JSON)

Test plan

  • cargo +nightly fmt --check — clean
  • cargo clippy --workspace --features full -- -D warnings — clean
  • cargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins — 9184/9184 passed

Closes #3593

mcpls v0.3.6 changed get_diagnostics to return {"diagnostics": [...]}
instead of a bare array. The old parser expected a bare array and
silently returned None on every call, preventing LSP diagnostics from
ever being injected into the prompt.

Replace the direct Vec<_> deserialization with a parse_diagnostics_json
helper that accepts both the legacy bare-array format and the
object-wrapper format by extracting .get("diagnostics") when present.

Adds regression test and 4 edge-case unit tests (bare array, empty
wrapper, missing key, invalid JSON). All 9184 tests pass.

Closes #3593
@github-actions github-actions Bot added rust Rust code changes core zeph-core crate bug Something isn't working size/M Medium PR (51-200 lines) labels May 5, 2026
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label May 5, 2026
@bug-ops bug-ops enabled auto-merge (squash) May 5, 2026 11:26
@bug-ops bug-ops merged commit 215c671 into main May 5, 2026
32 checks passed
@bug-ops bug-ops deleted the 3593-lsp-diagnostics-parse branch May 5, 2026 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core zeph-core crate documentation Improvements or additions to documentation rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lsp diagnostics injection silently fails: mcpls returns object, zeph-core expects array

1 participant