Skip to content

fix(bridge): diagnostic dedup drops distinct errors sharing same range, severity, and code #164

Description

@bug-ops

Description

DiagnosticDedupKey uses (range, severity, code) when code is present, ignoring the message entirely. Two genuinely distinct diagnostics at the same span with the same error code — for example, two E0308 type-mismatch errors arising from different unsatisfied trait bounds — have the second one silently dropped.

This is the opposite of the dedup's intent: instead of removing duplicates, it hides real errors.

Reproduction Steps

  1. Write Rust code that produces two E0308 errors at the same character position (e.g. a value that fails two independent trait constraints simultaneously)
  2. Call get_diagnostics via MCP
  3. Observe: only one of the two errors is returned

Expected Behavior

All distinct diagnostics should be returned; only exact duplicates (same range, severity, code, AND message) should be collapsed.

Actual Behavior

Any two diagnostics with the same (range, severity, code) are treated as duplicates regardless of their messages.

Affected Code

  • crates/mcpls-core/src/bridge/translator.rsDiagnosticDedupKey construction

Fix Direction

Include the message (or a hash of it) in DiagnosticDedupKey unconditionally, regardless of whether code is present:

DiagnosticDedupKey {
    range: ...,
    severity: ...,
    code: diag.code.clone(),
    message: diag.message.clone(),  // always include
}

Environment

  • Reproducible with any LSP server that emits multiple diagnostics at the same position with the same error code
  • rust-analyzer, pyright, and tsgo all produce such diagnostics in certain scenarios

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium: suboptimal behavior, minor inconsistencybugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions