{"record":{"id":"3b2bc42a29a96db5","repo":"coreybutler/nvm-windows","slug":"numeric-prerelease-version-must-not-contain-leadin","errorCode":null,"errorMessage":"Numeric PreRelease version must not contain leading zeroes %q","messagePattern":"Numeric PreRelease version must not contain leading zeroes %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/semver/semver.go","lineNumber":301,"sourceCode":"\treturn v, nil\n}\n\n// PreRelease Version\ntype PRVersion struct {\n\tVersionStr string\n\tVersionNum uint64\n\tIsNum      bool\n}\n\n// Creates a new valid prerelease version\nfunc NewPRVersion(s string) (*PRVersion, error) {\n\tif len(s) == 0 {\n\t\treturn nil, errors.New(\"Prerelease is empty\")\n\t}\n\tv := &PRVersion{}\n\tif containsOnly(s, numbers) {\n\t\tif hasLeadingZeroes(s) {\n\t\t\treturn nil, fmt.Errorf(\"Numeric PreRelease version must not contain leading zeroes %q\", s)\n\t\t}\n\t\tnum, err := strconv.ParseUint(s, 10, 64)\n\n\t\t// Might never be hit, but just in case\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tv.VersionNum = num\n\t\tv.IsNum = true\n\t} else if containsOnly(s, alphanum) {\n\t\tv.VersionStr = s\n\t\tv.IsNum = false\n\t} else {\n\t\treturn nil, fmt.Errorf(\"Invalid character(s) found in prerelease %q\", s)\n\t}\n\treturn v, nil\n}\n","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/coreybutler/nvm-windows/blob/5b18223ca19ff50d707f35410dbc6bd440a9f74d/src/semver/semver.go#L283-L319","documentation":"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).","triggerScenarios":"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.","commonSituations":"Zero-padded prerelease counters from build pipelines (1.0.0-beta.02), calendar-padded nightly identifiers, or hand-written versions copied from padded changelogs.","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"],"exampleFix":"// before\nv, err := semver.NewVersion(\"1.2.3-rc.01\")\n\n// after\nv, err := semver.NewVersion(\"1.2.3-rc.1\")","handlingStrategy":"validation","validationCode":"var numericIdent = regexp.MustCompile(`^(0|[1-9]\\d*)$`)\nfunc validPrerelease(pre string) bool {\n    for _, id := range strings.Split(pre, \".\") {\n        if isAllDigits(id) && !numericIdent.MatchString(id) { return false }\n    }\n    return true\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["semver","prerelease","validation","leading-zero"],"backgroundTag":null,"analyzedSha":"5b18223ca19ff50d707f35410dbc6bd440a9f74d","analyzedAt":"2026-08-15T10:06:51.428Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}