JuliusBrussee/caveman · error
invalid or oversized JSON number
Error message
invalid or oversized JSON number
What it means
Error from normalizeJSONNumber while canonicalizing a JSON number for PostgreSQL jsonb storage: the mantissa has no integer digits or its total coefficient digits exceed the allowed jsonb number coefficient limit, so the literal cannot be stored as a jsonb numeric.
Solutions
- Rescale or round the number before storing it (e.g. exponent-form very large/small values)
- Store the value as a string if exact display matters more than numeric typing
- Reject the input at the API boundary with a clearer domain-specific message
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at shared/platform/proposalrun/proposalrun.go:212 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/f77563b52a8c29ad.
Report an issue: GitHub.
Appendix: source
Thrown at shared/platform/proposalrun/proposalrun.go:212
mantissaEnd = i
var err error
exponent, err = parseJSONExponent(literal[i+1:])
if err != nil {
return "", err
}
}
mantissa := literal[start:mantissaEnd]
dot := strings.IndexByte(mantissa, '.')
if dot < 0 {
dot = len(mantissa)
}
integerPart := mantissa[:dot]
fractionPart := ""
if dot < len(mantissa) {
fractionPart = mantissa[dot+1:]
}
if len(integerPart) == 0 || len(integerPart)+len(fractionPart) > maxJSONBNumberCoefficient {
return "", fmt.Errorf("invalid or oversized JSON number")
}
for i := 0; i < len(integerPart); i++ {
if integerPart[i] < '0' || integerPart[i] > '9' {
return "", fmt.Errorf("invalid JSON number")
}
}
for i := 0; i < len(fractionPart); i++ {
if fractionPart[i] < '0' || fractionPart[i] > '9' {
return "", fmt.Errorf("invalid JSON number")
}
}
// PostgreSQL numeric retains the input display scale in jsonb output,
// including trailing fractional zeroes. Validate the raw scale before the
// canonical reduction below strips those zeroes; otherwise a value such as
// 1.0000e-16383 would reduce to a representable scale while its original
// jsonb insert would fail at the 16383-digit numeric limit.
rawScale := len(fractionPart) - exponent
if rawScale > maxJSONBNumericFractionDigits {View on GitHub (pinned to 3ee70a1026)