{"id":"e810c4334ae3b790","repo":"go-redis/redis","slug":"redis-s-value-d-is-below-minimum-allowed-value","errorCode":null,"errorMessage":"redis: %s value %d is below minimum allowed value %d","messagePattern":"redis: (.+?) value (.+?) is below minimum allowed value (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/util/convert.go","lineNumber":38,"sourceCode":"\treturn strconv.ParseFloat(s, 64)\n}\n\n// MustParseFloat is like ParseFloat but panics on parse errors.\nfunc MustParseFloat(s string) float64 {\n\tf, err := ParseStringToFloat(s)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"redis: failed to parse float %q: %v\", s, err))\n\t}\n\treturn f\n}\n\n// SafeIntToInt32 safely converts an int to int32, returning an error if overflow would occur.\nfunc SafeIntToInt32(value int, fieldName string) (int32, error) {\n\tif value > math.MaxInt32 {\n\t\treturn 0, fmt.Errorf(\"redis: %s value %d exceeds maximum allowed value %d\", fieldName, value, math.MaxInt32)\n\t}\n\tif value < math.MinInt32 {\n\t\treturn 0, fmt.Errorf(\"redis: %s value %d is below minimum allowed value %d\", fieldName, value, math.MinInt32)\n\t}\n\treturn int32(value), nil\n}\n","sourceCodeStart":20,"sourceCodeEnd":42,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/internal/util/convert.go#L20-L42","documentation":"Returned by util.SafeIntToInt32 when an int value is below math.MinInt32 (-2,147,483,648). Same path as the overflow case; it guards the negative bound before the int->int32 cast used for pool sizing fields. Negative pool sizes are nonsensical, so this surfaces a malformed config.","triggerScenarios":"Setting a pool option (PoolSize/MinIdleConns/MaxIdleConns/MaxActiveConns) to a large negative number whose magnitude exceeds MinInt32, or directly calling util.SafeIntToInt32 with such a value.","commonSituations":"A signed arithmetic bug producing a very large negative, or an uninitialised/garbage config value interpreted as int. Far rarer than the overflow case since negative pool sizes are already invalid.","solutions":["Use a non-negative value for the pool option.","Validate config at load time and reject values < 0 for these fields.","Set the field to 0 to take the go-redis default."],"exampleFix":"// before\nopt := &redis.Options{MinIdleConns: -(1 << 33)}\n// after\nopt := &redis.Options{MinIdleConns: 10}","handlingStrategy":"validation","validationCode":"func nonNegPoolInt(v int) (int32, error) {\n    if v < 0 { return 0, fmt.Errorf(\"pool field must be >= 0, got %d\", v) }\n    return util.SafeIntToInt32(v, \"pool\")\n}","typeGuard":"func isValidPoolInt(v int) bool { return v >= 0 && v <= math.MaxInt32 }","tryCatchPattern":null,"preventionTips":["Reject negative pool sizes in config validation.","Default unset fields to 0 rather than sentinel large-negative values.","Unit-test config parsing with negative inputs."],"tags":["config","pool","validation"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}