JuliusBrussee/caveman · error

JSON number exceeds PostgreSQL fraction-digit limit

Error message

JSON number exceeds PostgreSQL fraction-digit limit

What it means

Error "JSON number exceeds PostgreSQL fraction-digit limit" thrown in JuliusBrussee/caveman.

Source

Thrown at shared/platform/proposalrun/proposalrun.go:231

	}
	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 {
		return "", fmt.Errorf("JSON number exceeds PostgreSQL fraction-digit limit")
	}

	digits := strings.TrimLeft(integerPart+fractionPart, "0")
	if digits == "" {
		return "0", nil
	}
	scale := len(fractionPart) - exponent
	for scale > 0 && strings.HasSuffix(digits, "0") {
		digits = digits[:len(digits)-1]
		scale--
	}

	var out string
	switch {
	case scale <= 0:
		zeros := -scale
		if zeros > maxJSONBNumericIntegerDigits-len(digits) {
			return "", fmt.Errorf("JSON number exceeds PostgreSQL integer-digit limit")

View on GitHub (pinned to 27d5a3981a)

Solutions

  1. Reduce the number's fraction digits below the PostgreSQL limit.

When it happens

Trigger: Thrown at shared/platform/proposalrun/proposalrun.go:231 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15). Data as JSON: /api/errors/bbc0c156fef0461f. Report an issue: GitHub.