vitessio/vitess · warning · ErrOverflow
cannot parse int64 from %q: %w
Error message
cannot parse int64 from %q: %w
What it means
ParseInt64 reports overflow (wrapping ErrOverflow) when a positive value's accumulated digits reach or exceed the cutoff MaxInt64/base+1 during the digit loop, meaning the remaining digits cannot possibly fit in an int64. It returns math.MaxInt64 as the best-effort value.
Source
Thrown at go/mysql/fastparse/fastparse.go:195
default:
break next
}
if b >= byte(base) {
break next
}
var cutoff uint64
switch base {
case 10:
cutoff = math.MaxInt64/10 + 1
case 16:
cutoff = math.MaxInt64/16 + 1
default:
cutoff = math.MaxInt64/uint64(base) + 1
}
if !minus && d >= cutoff {
return math.MaxInt64, fmt.Errorf("cannot parse int64 from %q: %w", s, ErrOverflow)
}
if minus && d > cutoff {
return math.MinInt64, fmt.Errorf("cannot parse int64 from %q: %w", s, ErrOverflow)
}
d = d*uint64(base) + uint64(b)
i++
}
v := int64(d)
if d > math.MaxInt64 && !minus {
return math.MaxInt64, fmt.Errorf("cannot parse int64 from %q: %w", s, ErrOverflow)
} else if d > math.MaxInt64+1 && minus {
return math.MinInt64, fmt.Errorf("cannot parse int64 from %q: %w", s, ErrOverflow)
}
if minus {View on GitHub (pinned to 01a25a7d17)
Solutions
- Use errors.Is(err, fastparse.ErrOverflow) to distinguish overflow from syntax errors and handle it explicitly (clamp, reject, or switch to uint64 parsing).
- Parse with fastparse.ParseUint64 instead if the value legitimately fits in the unsigned range.
- Clamp to math.MaxInt64 (the returned value already does this) and log a warning if clamping is acceptable.
Example fix
// before
v, err := fastparse.ParseInt64(s, 10)
// after
v, err := fastparse.ParseInt64(s, 10)
if errors.Is(err, fastparse.ErrOverflow) {
return vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "value %q exceeds int64 range", s)
} Defensive patterns
Strategy: validation
Validate before calling
func fitsInt64(s string) bool {
v, err := fastparse.ParseInt64(strings.TrimSpace(s), 10)
return err == nil || !errors.Is(err, fastparse.ErrOverflow)
_ = v
} Try / catch
v, err := fastparse.ParseInt64(s, 10)
if errors.Is(err, fastparse.ErrOverflow) {
return vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "value %q overflows int64", s)
} Prevention
- Use ParseUint64 when values may legitimately exceed MaxInt64.
- Range-check oversized literals with math/big before coercion.
- Distinguish overflow via errors.Is(err, fastparse.ErrOverflow), never string matching.
When it happens
Trigger: Calling fastparse.ParseInt64 with a positive decimal (or any-base) string whose magnitude exceeds math.MaxInt64, e.g. ParseInt64("9223372036854775808", 10) or ParseInt64("FFFFFFFFFFFFFFFF", 16).
Common situations: Parsing user-supplied SQL integer literals that exceed the signed 64-bit range, importing data meant for BIGINT UNSIGNED into an int64 field, or id/sequence values from another system that used unsigned 64-bit IDs.
Related errors
- overflow
- unparsed tail left after parsing int64 from %q: %q
- invalid int64 value for %v: %v
- stray %% at the end of pattern
- too many .s
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/21bf7bd7cfbc0d91.
Report an issue: GitHub.