Skip to content

[Compare] Diff engine: duplicate match keys silently vanish; nested-object values compare as equal #77

Description

@Exotic209093

Severity

Medium — two fidelity gaps in the shared diff engine (local file diff, snapshot compare, org compare).

What happens

  1. Records load into a Map keyed by String(rec[matchField])Map.set keeps only the last row per key, no warning. The default org-compare key is Name, routinely non-unique: 3 rows named "Acme" → only one compared, summary.total undercounts, and with [Compare] Org-compare “Copy to target” inserts duplicates for Changed records #52 the wrong record can be synced.
  2. Field comparison is String(sv ?? '') !== String(tv ?? '') — object values stringify to [object Object], so records whose nested values differ (Owner: {Name:'A'} vs {Name:'B'}) land in Unchanged.

Evidence

  • src/ui/utils/dataDiff.ts:40-50 (duplicates), :73 (nested compare)
  • tests/unit/dataDiff.test.ts:37 covers blank keys only.

Suggested fix

Detect duplicate keys and surface a count/warning in the result and UI; JSON.stringify non-null object values before comparing (and display them the same way).

Environment

Commit 74cf21b (main), WaveLink 0.6.0. Found in the 2026-08-31 adversarial audit (code-verified).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions