Masterminds / semver

Work with Semantic Versions in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Regression in v3 or unexpected breaking behavior for NewConstraint(str)

consideRatio opened this issue · comments

I experienced a downstream issue in Helm v3 that worked well in Helm v2. This issue relates to a change of masterminds/semver v2 to v3.

The downstream issue is described here briefly, but it is really an upstream issue of masterminds/semver, and is reproducible in this Go Playground.

In short, the 001 variant of the following versions are now causing an issue for the NewConstraint() function.

	var version = ""
	version = "0.9.0-alpha.100" // OK
	version = "0.9.0-alpha.001" // ERROR
	var err error
	
	_, err = semver.NewConstraint(version)
	if err != nil {
		fmt.Println(err)
	} else {
        	fmt.Println("Everything is OK!")
	}

It relates to these changes by @mattfarina, that excludes the use of versions with leading zeroes:
23f51de#diff-ccde124315e74e68fae484840d08dff5

I've pinpointed that this is a breaking change to me only because now the semver specification is followed properly.

Numeric identifiers MUST NOT include leading zeroes.

ref: https://semver.org/#spec-item-9 (from item 9)

@consideRatio sorry for the slow response. It's the holidays so responses are slow right now.

You are right about the semver lib now following the specification. That's the reason. Most of the changes to v3 are behavior based rather than Go API based. This is one of them.