{"record":{"id":"02223c7473f58a9b","repo":"benbjohnson/litestream","slug":"size-d-exceeds-maximum-allowed-value-d","errorCode":null,"errorMessage":"size %d exceeds maximum allowed value (%d)","messagePattern":"size (.+?) exceeds maximum allowed value \\((.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/main.go","lineNumber":1105,"sourceCode":"\n// ParseByteSize parses a byte size string using github.com/dustin/go-humanize.\n// Supports both SI units (KB=1000, MB=1000², etc.) and IEC units (KiB=1024, MiB=1024², etc.).\n// Examples: \"1MB\", \"5MiB\", \"1.5GB\", \"100B\", \"1024KB\"\nfunc ParseByteSize(s string) (int64, error) {\n\ts = strings.TrimSpace(s)\n\tif s == \"\" {\n\t\treturn 0, fmt.Errorf(\"empty size string\")\n\t}\n\n\t// Use go-humanize to parse the byte size string\n\tbytes, err := humanize.ParseBytes(s)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"invalid size format: %w\", err)\n\t}\n\n\t// Check that the value fits in int64\n\tif bytes > math.MaxInt64 {\n\t\treturn 0, fmt.Errorf(\"size %d exceeds maximum allowed value (%d)\", bytes, int64(math.MaxInt64))\n\t}\n\n\treturn int64(bytes), nil\n}\n\n// ReplicaSettings contains settings shared across replica configurations.\n// These can be set globally in Config or per-replica in ReplicaConfig.\ntype ReplicaSettings struct {\n\tSyncInterval       *time.Duration `yaml:\"sync-interval\"`\n\tValidationInterval *time.Duration `yaml:\"validation-interval\"`\n\n\t// Maximum L0 files to upload in a single monitor sync run.\n\t// Set to zero to process all pending L0 files in one run.\n\tMaxSyncLTXFiles *int `yaml:\"max-sync-ltx-files\"`\n\n\t// If true, automatically reset local state when LTX errors are detected.\n\t// This allows recovery from corrupted/missing LTX files by forcing a fresh sync.\n\t// Disabled by default to prevent silent data loss scenarios.","sourceCodeStart":1087,"sourceCodeEnd":1123,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/main.go#L1087-L1123","documentation":"ParseByteSize guards that the parsed unsigned value fits in an int64. go-humanize returns uint64, so astronomically large values (e.g. \"20EiB\") exceed math.MaxInt64 and are rejected rather than silently overflowing negative.","triggerScenarios":"A size config value parses successfully but is larger than 9223372036854775807 bytes, e.g. \"10EB\", \"9223372036854775808\", \"20EiB\".","commonSituations":"Copy-pasted placeholder or sentinel values like \"9999999999999999999GB\"; a user trying to express \"unlimited\" as a huge size.","solutions":["Use a realistic size below 8 EiB (int64 max bytes)","If the intent is 'no limit', omit the field or use the documented default rather than a huge value","Verify the value after unit parsing: \"1000000TB\" still overflows"],"exampleFix":"# before\nmax-size: 20EiB\n# after\nmax-size: 1TB","handlingStrategy":"validation","validationCode":"if n, err := humanize.ParseBytes(cfg.Size); err == nil && n > math.MaxInt64 {\n    return fmt.Errorf(\"size %q exceeds int64 max\", cfg.Size)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never use huge sentinel sizes to mean 'unlimited'; omit the field instead","Sanity-check parsed sizes against a realistic upper bound in CI","Document that sizes must fit in int64"],"tags":["config","size","overflow"],"backgroundTag":"value-out-of-range","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}