coreybutler/nvm-windows · error
Numeric PreRelease version must not contain leading zeroes %
Error message
Numeric PreRelease version must not contain leading zeroes %q
What it means
Semver parse error from NewPRVersion(): a prerelease identifier that is entirely numeric contains a leading zero (e.g. pre-release "01" in 1.2.3-01). Numeric prerelease identifiers must not have leading zeros under SEMVER 2.0.0 (alphanumeric ones like 'alpha01' are fine).
Source
Thrown at src/semver/semver.go:301
return v, nil
}
// PreRelease Version
type PRVersion struct {
VersionStr string
VersionNum uint64
IsNum bool
}
// Creates a new valid prerelease version
func NewPRVersion(s string) (*PRVersion, error) {
if len(s) == 0 {
return nil, errors.New("Prerelease is empty")
}
v := &PRVersion{}
if containsOnly(s, numbers) {
if hasLeadingZeroes(s) {
return nil, fmt.Errorf("Numeric PreRelease version must not contain leading zeroes %q", s)
}
num, err := strconv.ParseUint(s, 10, 64)
// Might never be hit, but just in case
if err != nil {
return nil, err
}
v.VersionNum = num
v.IsNum = true
} else if containsOnly(s, alphanum) {
v.VersionStr = s
v.IsNum = false
} else {
return nil, fmt.Errorf("Invalid character(s) found in prerelease %q", s)
}
return v, nil
}
View on GitHub (pinned to 5b18223ca1)
Solutions
- Remove leading zeroes from numeric prerelease identifiers: 1.2.3-01 -> 1.2.3-1
- Make the identifier alphanumeric if padding must be preserved: 1.2.3-build02
- Fix the release script that emits padded numeric identifiers
Example fix
// before
v, err := semver.NewVersion("1.2.3-rc.01")
// after
v, err := semver.NewVersion("1.2.3-rc.1") Defensive patterns
Strategy: validation
Validate before calling
var numericIdent = regexp.MustCompile(`^(0|[1-9]\d*)$`)
func validPrerelease(pre string) bool {
for _, id := range strings.Split(pre, ".") {
if isAllDigits(id) && !numericIdent.MatchString(id) { return false }
}
return true
} Prevention
- Format prerelease counters without padding (%d, never %02d)
- Keep padded identifiers alphanumeric (build02, not 02) to sidestep the rule
- Unit-test version parsing against the full semver.org spec corpus
When it happens
Trigger: semver.NewVersion("1.2.3-01"), "1.2.3-rc.007", or any dash-separated prerelease part where a dot-delimited identifier is all digits and starts with '0' but is not '0' itself.
Common situations: Zero-padded prerelease counters from build pipelines (1.0.0-beta.02), calendar-padded nightly identifiers, or hand-written versions copied from padded changelogs.
Related errors
- Patch number must not contain leading zeroes %q
- Invalid character(s) found in prerelease %q
- Invalid character(s) found in patch number %q
- Invalid character(s) found in build meta data %q
- Unrecognized version: "%s"
AI-assisted analysis of coreybutler/nvm-windows@5b18223ca1 (2026-08-15).
Data as JSON: /api/errors/3b2bc42a29a96db5.
Report an issue: GitHub.