{"record":{"id":"d88c6ef08706ae3d","repo":"nats-io/nats-server","slug":"integer-s-is-out-of-the-range","errorCode":null,"errorMessage":"integer '%s' is out of the range","messagePattern":"integer '(.+?)' is out of the range","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"conf/parse.go","lineNumber":314,"sourceCode":"\tcase itemMapEnd:\n\t\tsetValue(it, p.popContext())\n\tcase itemString:\n\t\t// FIXME(dlc) sanitize string?\n\t\tsetValue(it, it.val)\n\tcase itemInteger:\n\t\tlastDigit := 0\n\t\tfor _, r := range it.val {\n\t\t\tif !unicode.IsDigit(r) && r != '-' {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tlastDigit++\n\t\t}\n\t\tnumStr := it.val[:lastDigit]\n\t\tnum, err := strconv.ParseInt(numStr, 10, 64)\n\t\tif err != nil {\n\t\t\tif e, ok := err.(*strconv.NumError); ok &&\n\t\t\t\te.Err == strconv.ErrRange {\n\t\t\t\treturn fmt.Errorf(\"integer '%s' is out of the range\", it.val)\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"expected integer, but got '%s'\", it.val)\n\t\t}\n\t\t// Process a suffix\n\t\tsuffix := strings.ToLower(strings.TrimSpace(it.val[lastDigit:]))\n\n\t\tswitch suffix {\n\t\tcase \"\":\n\t\t\tsetValue(it, num)\n\t\tcase \"k\":\n\t\t\tsetValue(it, num*1000)\n\t\tcase \"kb\", \"ki\", \"kib\":\n\t\t\tsetValue(it, num*1024)\n\t\tcase \"m\":\n\t\t\tsetValue(it, num*1000*1000)\n\t\tcase \"mb\", \"mi\", \"mib\":\n\t\t\tsetValue(it, num*1024*1024)\n\t\tcase \"g\":","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/conf/parse.go#L296-L332","documentation":"When a config value looks like a number with a size suffix (e.g. 2GB, 1024KB), processItem parses the digit part with strconv.ParseInt on 64 bits. If parsing fails specifically with ErrRange, the value overflows int64 and the parser reports \"integer '<value>' is out of the range\".","triggerScenarios":"Any numeric config value whose integer magnitude exceeds int64 range even before suffix application — e.g. `max_payload: 99999999999999999999`, or durations/sizes with absurdly large digit strings in conf values parsed by processItem's numeric branch.","commonSituations":"Fat-fingered extra digits; generation of configs from scripts concatenating numbers; unit confusion leading to giant numbers like 9999PB written as raw digit strings.","solutions":["Reduce the literal to a value within int64 (max 9223372036854775807)","Use suffixes (KB/MB/GB) instead of enormous raw numbers","Check for accidentally duplicated digits in generated configs","Validate the config with `nats-server -t` before deployment"],"exampleFix":"// before\nmax_payload: 99999999999999999999\n// after\nmax_payload: 1GB","handlingStrategy":"validation","validationCode":"func checkInt64(v string) error {\n    if _, err := strconv.ParseInt(strings.TrimRight(v, \"KMGTPBkmgtpb\"), 10, 64); err != nil {\n        if errors.Is(err, strconv.ErrRange) {\n            return fmt.Errorf(\"%s exceeds int64 range\", v)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use KB/MB/GB suffixes instead of raw enormous literals","Bound generated numbers in config templating scripts","Add a range check in config generation pipelines","Run nats-server -t before deployment"],"tags":["config","integer-overflow","parser","nats-server"],"backgroundTag":"integer-out-of-range","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}