Skip to content

Skip BOM download when version contains unresolved placeholders#6674

Merged
Jenson3210 merged 2 commits intomainfrom
fix-unresolved-bom-var
Feb 4, 2026
Merged

Skip BOM download when version contains unresolved placeholders#6674
Jenson3210 merged 2 commits intomainfrom
fix-unresolved-bom-var

Conversation

@Jenson3210
Copy link
Copy Markdown
Contributor

Summary

  • Skip downloading BOM POM when the version contains unresolved Gradle variable placeholders
  • Prevents IllegalArgumentException from URI.create() when ${...} characters appear in the download URL

Problem

When a Gradle build uses the Spring dependency-management plugin with a mavenBom that references a Gradle variable:

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}

The SpringDependencyManagementPluginEntry trait stores the version as the literal string ${springCloudVersion}. RemoveRedundantDependencyVersions then passes this unresolved version directly to MavenPomDownloader.download(), which constructs a URL containing ${...} causing IllegalArgumentException.

Solution

Added a guard to skip the BOM download when the version is null or contains unresolved ${ placeholders. Dependencies managed by other BOMs with resolved versions (like Spring Boot) continue to work correctly. Dependencies managed only by the unresolved BOM conservatively keep their explicit versions rather than crashing.

Test plan

  • New test mavenBomWithUnresolvedVariable reproduces the exact IllegalArgumentException
  • All existing RemoveRedundantDependencyVersionsTest tests pass

Reproduces IllegalArgumentException when RemoveRedundantDependencyVersions
encounters a mavenBom dependency that uses a Gradle variable reference like
${springCloudVersion}. The unresolved placeholder is passed to
MavenPomDownloader.download() which fails in URI.create().
When a mavenBom entry in the Spring dependency-management plugin uses a
Gradle variable (e.g. ${springCloudVersion}), the version is stored as
a literal placeholder string. Passing this to MavenPomDownloader.download()
causes IllegalArgumentException from URI.create() because ${ is not valid
in a URI path.

Skip the download attempt when the version contains unresolved ${}
placeholders, consistent with how the recipe already handles missing
versions.
@github-project-automation github-project-automation Bot moved this from In Progress to Ready to Review in OpenRewrite Feb 4, 2026
@Jenson3210 Jenson3210 merged commit b8612b5 into main Feb 4, 2026
2 checks passed
@Jenson3210 Jenson3210 deleted the fix-unresolved-bom-var branch February 4, 2026 12:31
@github-project-automation github-project-automation Bot moved this from Ready to Review to Done in OpenRewrite Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants