Skip to content

fix(diff): keep components that share a key instead of silently dropping them - #70

Merged
dmchaledev merged 1 commit into
mainfrom
fix/component-key-collisions
Aug 7, 2026
Merged

fix(diff): keep components that share a key instead of silently dropping them#70
dmchaledev merged 1 commit into
mainfrom
fix/component-key-collisions

Conversation

@dmchaledev

Copy link
Copy Markdown
Contributor

Closes #50

Problem

buildComponentMap used last-write-wins on the purl/name key: when one SBOM contained two components with the same key (purl-less same-name packages in OS/container SBOMs, or distinct purls collapsing to one coordinate), every entry but the last vanished before the diff ran — so added/removed packages could disappear from the report entirely.

Fix

Verification

  • 2 new tests: same-key removal is reported; same-key pairs match by occurrence order (upgrade, not add+remove)
  • 112 tests pass, tsc clean

…ing them

Closes #50

buildComponentMap used last-write-wins on the purl/name key: when one SBOM
contained two components with the same key (purl-less same-name packages in
OS/container SBOMs, distinct purls collapsing to one coordinate), every entry
but the last vanished before the diff ran — so added/removed packages could
disappear from the report entirely.

- Every component now gets a unique key: first occurrence keeps the bare key,
  collisions get a #2/#3 suffix. All entries survive into the diff.
- Deterministic: stable input order yields stable keys.
- 2 new tests: same-key removal is reported; same-key pairs match by
  occurrence order (upgrade, not add+remove).

112 tests pass, tsc clean.
@dmchaledev
dmchaledev force-pushed the fix/component-key-collisions branch from 25a45d5 to bea3a94 Compare August 7, 2026 19:36
@dmchaledev
dmchaledev merged commit a027cd5 into main Aug 7, 2026
2 checks passed
@dmchaledev
dmchaledev deleted the fix/component-key-collisions branch August 7, 2026 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant