From 8836da89cea36d64112c1849b7b978e19462262e Mon Sep 17 00:00:00 2001 From: Xueqin Cui Date: Fri, 29 May 2026 15:02:26 +1000 Subject: [PATCH 1/2] fix(util/semver): handle empty constraint for Maven --- util/semver/constraint.go | 2 +- util/semver/maven_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/util/semver/constraint.go b/util/semver/constraint.go index 8e2e27c0..727afdf0 100644 --- a/util/semver/constraint.go +++ b/util/semver/constraint.go @@ -74,7 +74,7 @@ func (sys System) ParseConstraint(str string) (retC *Constraint, retErr error) { // creating the empty set, which means the opposite. lexStr := str if lexStr == "" { - if sys == NuGet { + if sys == NuGet || sys == Maven { return nil, fmt.Errorf("invalid empty constraint") } lexStr = ">=0.0.0" diff --git a/util/semver/maven_test.go b/util/semver/maven_test.go index 05b9f381..f108b3d6 100644 --- a/util/semver/maven_test.go +++ b/util/semver/maven_test.go @@ -87,6 +87,7 @@ var mavenConstraintErrorTests = []constraintErrorTest{ {"(1.0)", "hard requirement must be closed on both ends in `(1.0)`"}, {"[1.0]]2.0]", "unexpected rbracket in `[1.0]]2.0]`"}, {"[1.0][2.0]", "unexpected lbracket in `[1.0][2.0]`"}, + {"", "invalid empty constraint"}, } func TestMavenConstraintError(t *testing.T) { From 793e95b6d7acd661c62df009faa2a4e3898fecf5 Mon Sep 17 00:00:00 2001 From: Xueqin Cui Date: Fri, 29 May 2026 15:22:38 +1000 Subject: [PATCH 2/2] nit --- util/semver/maven_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/semver/maven_test.go b/util/semver/maven_test.go index f108b3d6..eb7375e1 100644 --- a/util/semver/maven_test.go +++ b/util/semver/maven_test.go @@ -81,13 +81,13 @@ func TestMavenCanon(t *testing.T) { } var mavenConstraintErrorTests = []constraintErrorTest{ + {"", "invalid empty constraint"}, {"[", "expected comma or closing bracket in `[`"}, {"()", "hard requirement must be closed on both ends in `()`"}, {")", "unexpected rbracket in `)`"}, {"(1.0)", "hard requirement must be closed on both ends in `(1.0)`"}, {"[1.0]]2.0]", "unexpected rbracket in `[1.0]]2.0]`"}, {"[1.0][2.0]", "unexpected lbracket in `[1.0][2.0]`"}, - {"", "invalid empty constraint"}, } func TestMavenConstraintError(t *testing.T) {