Skip to content

fix: handle duplicate dependency names in parseMetadataLinks#700

Merged
truggeri merged 2 commits intodependabot:mainfrom
tv2:fix/duplicate-dependency-name-version-confusion
Apr 9, 2026
Merged

fix: handle duplicate dependency names in parseMetadataLinks#700
truggeri merged 2 commits intodependabot:mainfrom
tv2:fix/duplicate-dependency-name-version-confusion

Conversation

@devantler
Copy link
Copy Markdown
Contributor

@devantler devantler commented Apr 9, 2026

Summary

parseMetadataLinks() uses a Map<string, dependencyVersions> to store version info parsed from metadata links in the commit message. When the same dependency name appears multiple times (e.g., picomatch updated via multiple transitive paths at different semver ranges like v2.x and v4.x), the Map's .set() overwrites earlier entries, keeping only the last version pair.

This causes calculateUpdateType() to compare mismatched versions, potentially classifying a patch bump as a major update.

Fix

  • Changed parseMetadataLinks return type to Map<string, dependencyVersions[]> — stores an array of version pairs per dependency name
  • Added a per-name counter in the consumer (nameCounters Map) to retrieve the correct version entry for each YAML dependency, matching the order they appear in metadata links

Test

Added a test case reproducing the exact scenario:

  • Two picomatch entries at different semver ranges (2.3.1→2.3.2 and 4.0.1→4.0.2)
  • Asserts each entry gets the correct version pair and both resolve to semver-patch

Fixes #699

When the same dependency name appears multiple times in a grouped update
(e.g., picomatch updated via multiple transitive paths at different semver
ranges), the Map in parseMetadataLinks would overwrite earlier entries,
keeping only the last version pair for that name. This caused
 2.3.2),
incorrectly classifying patch bumps as major updates.

Changed parseMetadataLinks to store an array of version pairs per dependency
name (Map<string, dependencyVersions[]>) and added a per-name counter in the
consumer to retrieve the correct entry for each YAML dependency in order.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes incorrect update-type classification when the same dependency name appears multiple times in Dependabot metadata links by preserving all version pairs and consuming them deterministically.

Changes:

  • Update parseMetadataLinks() to store multiple version pairs per dependency name (Map<string, dependencyVersions[]>) instead of overwriting.
  • Add per-dependency occurrence counters in the YAML consumer to select the correct version pair for each repeated dependency entry.
  • Add a regression test covering duplicate picomatch entries at different major ranges (2.x and 4.x).
Show a summary per file
File Description
src/dependabot/update_metadata.ts Store multiple metadata-link version pairs per dependency name and consume them via per-name indexing.
src/dependabot/update_metadata.test.ts Add test ensuring duplicate dependency names don’t mix version pairs and update types remain correct.
dist/index.js Update compiled output to reflect the TypeScript changes.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/3 changed files
  • Comments generated: 1

Comment thread src/dependabot/update_metadata.ts Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@truggeri truggeri merged commit 7798095 into dependabot:main Apr 9, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parseMetadataLinks overwrites duplicate dependency names, causing incorrect update-type

3 participants