nats-io/nats-server · error

float '%s' is out of the range

Error message

float '%s' is out of the range

What it means

During config parsing, an item classified as a float was parsed with strconv.ParseFloat, which returned a *strconv.NumError wrapping strconv.ErrRange. That means the literal is syntactically a number but its magnitude exceeds the float64 range (overflow to ±Inf or underflow toward 0 not representable). The parser rejects it instead of silently storing an Inf/0 value.

Source

Thrown at conf/parse.go:354

		case "t":
			setValue(it, num*1000*1000*1000*1000)
		case "tb", "ti", "tib":
			setValue(it, num*1024*1024*1024*1024)
		case "p":
			setValue(it, num*1000*1000*1000*1000*1000)
		case "pb", "pi", "pib":
			setValue(it, num*1024*1024*1024*1024*1024)
		case "e":
			setValue(it, num*1000*1000*1000*1000*1000*1000)
		case "eb", "ei", "eib":
			setValue(it, num*1024*1024*1024*1024*1024*1024)
		}
	case itemFloat:
		num, err := strconv.ParseFloat(it.val, 64)
		if err != nil {
			if e, ok := err.(*strconv.NumError); ok &&
				e.Err == strconv.ErrRange {
				return fmt.Errorf("float '%s' is out of the range", it.val)
			}
			return fmt.Errorf("expected float, but got '%s'", it.val)
		}
		setValue(it, num)
	case itemBool:
		switch strings.ToLower(it.val) {
		case "true", "yes", "on":
			setValue(it, true)
		case "false", "no", "off":
			setValue(it, false)
		default:
			return fmt.Errorf("expected boolean value, but got '%s'", it.val)
		}

	case itemDatetime:
		dt, err := time.Parse("2006-01-02T15:04:05Z", it.val)
		if err != nil {
			return fmt.Errorf(

View on GitHub (pinned to 3a66a489d2)

Solutions

  1. Edit the config value to a number within float64 range (|x| < ~1.7976931348623157e308).
  2. If a sentinel 'infinity' is intended, use a string or a large-but-valid literal like 1e308 and interpret it in application code.
  3. Check for accidental digit/zero repetition (pasted IDs, concatenated numbers).
  4. Quote the value as a string if you need the literal verbatim and will convert it yourself.

Example fix

// before
rate_limit = 1e400
// after
rate_limit = 1e308
Defensive patterns

Strategy: validation

Validate before calling

for _, v := range floatValues {
	f, err := strconv.ParseFloat(v, 64)
	if err != nil || math.IsInf(f, 0) {
		return fmt.Errorf("float %q out of float64 range", v)
	}
}

Prevention

When it happens

Trigger: processItem (invoked from parse) hits case itemFloat with it.val such as '1e400' or '1.8e309'; ParseFloat fails with ErrRange.

Common situations: Config files with placeholder or auto-generated huge numbers (e.g. sentinel values like 9999999999e999), copied constants from other languages beyond float64 max (~1.8e308), or typos with too many digits.

Related errors


AI-assisted analysis of nats-io/nats-server@3a66a489d2 (2026-09-02). Data as JSON: /api/errors/17148dc7fe32d5d5. Report an issue: GitHub.