fix: accept locally cached artifacts via same-id fallback when tracking URL changes - #2133
Merged
Merged
Conversation
…allback When the tracking key function is URL-qualified (nid_hurl, the default since 2.0.23), tracking entries written by an older resolver using ID-only keys (nid format, e.g. 'artifact>central=') are invisible to the new lookup which expects 'artifact>central-<sha1>='. This causes all artifacts cached in the local repository before the upgrade to appear as 'present but unavailable', triggering full re-downloads from remote repositories. In CI environments and integration tests that use fake/file-based repositories, this breaks resolution entirely. Add a backward-compatible fallback in applyTracking(): when the URL-qualified lookup misses, try the system-wide key function (which defaults to nid) as a fallback. If that matches, accept the artifact and log a debug message. The legacy entry will be upgraded to the new key format on the next download. This preserves the f013 security improvement (URL-qualified tracking prevents same-id-different-URL repository poisoning) while providing a smooth upgrade path from older resolvers.
cstamas
approved these changes
Sep 8, 2026
cstamas
approved these changes
Sep 8, 2026
|
@cstamas Please assign appropriate label to PR according to the type of change. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When the tracking key function is URL-qualified (
nid_hurl, the default since 2.0.23 / commit 339161b), tracked artifacts become unavailable in two situations:nidformat, e.g.artifact>central=).central-<sha1(realUrl)>=vs ITs overridingcentraltofile:target/nullwhich produces a different sha1).In both cases the artifact IS present and WAS downloaded from a repository with the same logical identity (same repo ID). The resolver currently forces a full re-download, which fails in CI environments and integration tests that use fake/file-based repository URLs — see apache/maven#13078 (comment).
All 9 IT jobs fail (4229 failures) because ITs override
centraltofile:target/nullto prevent remote access, butnid_hurltreatssha1(file:target/null)≠sha1(https://repo.maven.apache.org/maven2)as a different repository.Fix
Add a two-stage fallback in
applyTracking():nid, ID-only) — catches legacy tracking entries from older resolvers.repoId-— catches same-id entries written with a different URL hash (the IT scenario where central is redirected tofile:target/null).The entry will be upgraded to the current key format on the next download.
Tests
testUrlQualifiedTrackingDistinguishesSameIdDifferentUrl→testUrlQualifiedTrackingSameIdDifferentUrlAcceptedViaFallback: same-id-different-URL now acceptedtestUrlQualifiedTrackingAcceptsLegacyIdOnlyEntriesViaFallback: legacynidentries accepted via stage 1testUrlQualifiedTrackingRejectsLegacyIdOnlyEntriesFromDifferentRepo: different repo ID still rejectedtestUrlQualifiedTrackingAcceptsSameIdDifferentUrlEntries: IT scenario (Central →file:target/null) verified