Use LatestRelease for BOM version filtering in upgrade search#6908
Merged
Use LatestRelease for BOM version filtering in upgrade search#6908
Conversation
b496e2c to
133b260
Compare
When UpgradeDependencyVersion attempts to upgrade a BOM to find a version that manages a dependency at a target version, it iterates over available BOM versions from metadata and downloads each POM to check. If a BOM version is listed in metadata but its POM is unavailable (404), the MavenDownloadingException would propagate up and add spurious error markers to the document. This is the case for jackson-databind CVE patches: jackson-databind has versions 2.13.4.1 and 2.13.4.2, but jackson-bom does not have matching patch versions. When the metadata lists a non-existent BOM version, the download failure now gets caught inside the search loop and the next candidate version is tried instead.
Replace complex mock test with a simple test using real jackson-bom and jackson-databind artifacts from Maven Central. Add a focused mock test for the specific error path where a BOM version appears in metadata but its POM is unavailable.
When a dependency and its BOM import share the same version property
(e.g. ${jackson.version}), upgrading the dependency version would change
the property value globally, also pointing the BOM at the new version.
If the BOM doesn't publish a matching version (e.g. jackson-databind has
2.13.4.2 for a CVE fix but jackson-bom does not), this causes an
"Unable to download POM" error.
Now when the dependency version is a property that's also used by the
BOM import, the recipe replaces the property reference on the dependency
with the literal new version instead of changing the shared property.
Also catch MavenDownloadingException in the BOM version search loop so
that unavailable BOM POMs are skipped gracefully.
The BOM upgrade search in getAvailableBomVersions was using the dependency's version comparator to filter BOM versions. When the BOM uses a different versioning scheme than the dependency (e.g., jackson-bom uses 2.13.4.20221013 while jackson-databind uses 2.13.4.2), ExactVersion would reject valid BOM versions because they don't match the dependency version string exactly. This caused the BOM upgrade to fail silently, falling through to upgrade the dependency individually. If the dependency version was managed through a shared property with the BOM import, changing the property would also change the BOM to a non-existent version, producing "Unable to download POM" errors. Now uses LatestRelease to filter BOM versions, which accepts any valid release version newer than the current BOM version. The actual matching (does this BOM manage the target dependency at the target version?) is already handled in the iteration loop. Fixes moderneinc/customer-requests#1968
133b260 to
b914f85
Compare
The defensive try/catch is no longer needed now that the root cause is fixed — BOM versions are filtered correctly with LatestRelease.
timtebeek
approved these changes
Mar 11, 2026
Member
timtebeek
left a comment
There was a problem hiding this comment.
Thanks for working out & explaining this scenario!
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
LatestReleasefor filtering BOM versions instead of the dependency's version comparatorProblem
When
UpgradeDependencyVersionupgrades a dependency managed by a BOM, it first attempts to find a newer BOM version that manages the dependency at the target version. The BOM version search used the dependency'sversionComparatorto filter candidate BOM versions.This fails when the BOM uses a different versioning scheme than the dependency. For example, jackson-bom uses versions like
2.13.4.20221013while jackson-databind uses2.13.4.2. WithExactVersion("2.13.4.2"), the filter rejects2.13.4.20221013because it doesn't match exactly, so the BOM upgrade silently fails.The recipe then falls through to upgrade the dependency individually. If the version is managed through a shared property with the BOM import (e.g.,
${jackson.version}), changing the property also changes the BOM to a non-existent version, producing "Unable to download POM" errors.Solution
Use
LatestReleaseto filter BOM versions instead of the dependency'sversionComparator. This accepts any valid release version newer than the current BOM version. The actual matching (does this BOM manage the target dependency at the target version?) is already handled by the iteration loop infindNewerBomVersionWithDependency.Test plan
New test
upgradeBomWhenBomVersioningDiffersFromDependencyverifies jackson-bom upgrade from 2.13.4 to 2.13.4.20221013 when upgrading jackson-databind to 2.13.4.2Test fails without the fix (adds explicit version instead of upgrading BOM)
Existing BOM upgrade tests pass (
upgradeBomInsteadOfOverridingDependency,bomUpgradeSkipsSnapshotVersions)Full
UpgradeDependencyVersionTestsuite passesFixes moderneinc/customer-requests#1968