Skip to content

fix: normalise tomcat version wildcard + to * (fixes #1219)#1220

Merged
ramonskie merged 1 commit intomainfrom
fix/tomcat-version-wildcard-issue-1219
Mar 24, 2026
Merged

fix: normalise tomcat version wildcard + to * (fixes #1219)#1220
ramonskie merged 1 commit intomainfrom
fix/tomcat-version-wildcard-issue-1219

Conversation

@ramonskie
Copy link
Copy Markdown
Contributor

Summary

Fixes #1219 — staging failed with improper constraint: 10.1.+ when specifying a two-segment minor version wildcard in JBP_CONFIG_TOMCAT.

Root Cause

determineTomcatVersion converted single-segment patterns (9.+9.x, 10.+10.x) but passed multi-segment patterns through unchanged (10.1.+10.1.+). Neither blang/semver nor Masterminds/semver accept + as a wildcard suffix, so FindMatchingVersion("10.1.+", ...) always errored.

The same latent bug affected 10.23.+ — the old test for it asserted the broken pass-through value.

Fix

Replace + with * uniformly, consistent with jre.go's normalizeVersionPattern:

// before
if !strings.Contains(strings.TrimSuffix(pattern, ".+"), ".") {
    return strings.TrimSuffix(pattern, ".+") + ".x"
}
return pattern  // "10.1.+" passed through unchanged → breaks FindMatchingVersion

// after
return strings.ReplaceAll(match[1], "+", "*")
// "9.+" → "9.*", "10.+" → "10.*", "10.1.+" → "10.1.*", "10.23.+" → "10.23.*"

Masterminds/semver v1.5.0 treats x, X, and * as equivalent wildcards (isX() function), so all patterns resolve correctly.

Changes

  • src/java/containers/tomcat.go — simplified determineTomcatVersion to a single strings.ReplaceAll
  • src/java/containers/tomcat_test.go — updated expected values (9.x9.*, 10.x10.*, 10.23.+10.23.*) and added the missing 10.1.+ test case
  • src/integration/tomcat_test.go — regression integration test using the exact env var combination from the issue report

@ramonskie ramonskie force-pushed the fix/tomcat-version-wildcard-issue-1219 branch from 02fbc62 to 96af84e Compare March 24, 2026 13:44
Copy link
Copy Markdown
Contributor

@kiril-keranov kiril-keranov left a comment

Choose a reason for hiding this comment

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

lgtm

@ramonskie ramonskie merged commit d051cb9 into main Mar 24, 2026
1 check 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.

tomcat version resolution error for pattern "10.1.+": improper constraint: 10.1.+

2 participants