jeessy2/ddns-go · error
解析版本号时出错:%s
Error message
解析版本号时出错:%s
What it means
After the version regex matches, NewVersion parses the major component with strconv.ParseUint(m[1], 10, 64). This error wraps any failure converting the matched major part to an unsigned 64-bit integer, meaning the captured major segment is not a valid base-10 number (or overflows uint64).
Source
Thrown at util/semver/version.go:45
func init() {
versionRegex = regexp.MustCompile("^" + semVerRegex + "$")
}
// NewVersion 解析给定的版本并返回 Version 实例,如果
// 无法解析该版本则返回错误。如果版本是类似于 SemVer 的版本,则会
// 尝试将其转换为 SemVer。
func NewVersion(v string) (*Version, error) {
m := versionRegex.FindStringSubmatch(v)
if m == nil {
return nil, fmt.Errorf("the %s, it's not a semantic version", v)
}
sv := &Version{}
var err error
sv.major, err = strconv.ParseUint(m[1], 10, 64)
if err != nil {
return nil, fmt.Errorf("解析版本号时出错:%s", err)
}
if m[2] != "" {
sv.minor, err = strconv.ParseUint(strings.TrimPrefix(m[2], "."), 10, 64)
if err != nil {
return nil, fmt.Errorf("解析版本号时出错:%s", err)
}
} else {
sv.minor = 0
}
if m[3] != "" {
sv.patch, err = strconv.ParseUint(strings.TrimPrefix(m[3], "."), 10, 64)
if err != nil {
return nil, fmt.Errorf("解析版本号时出错:%s", err)
}
} else {
sv.patch = 0View on GitHub (pinned to 5874c2e666)
Solutions
- Check the version string in the error message for an oversized or malformed major component
- Cap/normalize the version string before parsing if it comes from an untrusted source
- Treat as unparseable and skip the update comparison, logging the raw input
Defensive patterns
Strategy: validation
Validate before calling
if len(majorStr) > 19 {
return fmt.Errorf("major component too large: %s", majorStr)
}
if _, err := strconv.ParseUint(majorStr, 10, 64); err != nil {
return err
} Try / catch
v, err := semver.NewVersion(input)
if err != nil {
log.Warnf("failed parsing version %q: %v", input, err)
return nil
} Prevention
- Sanitize version strings from untrusted sources
- Reject components longer than 19 digits (uint64 limit)
- Keep version strings machine-generated, not hand-edited
When it happens
Trigger: Calling NewVersion with a version whose major component overflows uint64 (e.g. a 20+ digit number) or, if the regex is permissive, contains characters that ParseUint rejects — essentially only reachable with pathological oversized inputs since regex validation usually guarantees digits.
Common situations: Garbage that happens to match the regex loosely (e.g. extremely long numeric strings from corrupted version files); versions with leading zeros are fine but astronomically large numbers are not.
Related errors
- the %s, it's not a semantic version
- failed to parse response data: %w
- failed to parse domain list: %w
- invalid response format: missing list field
- unknown response data format: %T
AI-assisted analysis of jeessy2/ddns-go@5874c2e666 (2026-09-03).
Data as JSON: /api/errors/17824598d1aae36d.
Report an issue: GitHub.