{"record":{"id":"61d89c82116e4cc2","repo":"grpc/grpc-go","slug":"min-v-is-greater-than-max-v","errorCode":null,"errorMessage":"min %v is greater than max %v","messagePattern":"min (.+?) is greater than max (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"balancer/ringhash/config.go","lineNumber":55,"sourceCode":"func parseConfig(c json.RawMessage) (*iringhash.LBConfig, error) {\n\tvar cfg iringhash.LBConfig\n\tif err := json.Unmarshal(c, &cfg); err != nil {\n\t\treturn nil, err\n\t}\n\tif cfg.MinRingSize > ringHashSizeUpperBound {\n\t\treturn nil, fmt.Errorf(\"min_ring_size value of %d is greater than max supported value %d for this field\", cfg.MinRingSize, ringHashSizeUpperBound)\n\t}\n\tif cfg.MaxRingSize > ringHashSizeUpperBound {\n\t\treturn nil, fmt.Errorf(\"max_ring_size value of %d is greater than max supported value %d for this field\", cfg.MaxRingSize, ringHashSizeUpperBound)\n\t}\n\tif cfg.MinRingSize == 0 {\n\t\tcfg.MinRingSize = defaultMinSize\n\t}\n\tif cfg.MaxRingSize == 0 {\n\t\tcfg.MaxRingSize = defaultMaxSize\n\t}\n\tif cfg.MinRingSize > cfg.MaxRingSize {\n\t\treturn nil, fmt.Errorf(\"min %v is greater than max %v\", cfg.MinRingSize, cfg.MaxRingSize)\n\t}\n\tif cfg.MinRingSize > envconfig.RingHashCap {\n\t\tcfg.MinRingSize = envconfig.RingHashCap\n\t}\n\tif cfg.MaxRingSize > envconfig.RingHashCap {\n\t\tcfg.MaxRingSize = envconfig.RingHashCap\n\t}\n\tif !envconfig.RingHashSetRequestHashKey {\n\t\tcfg.RequestHashHeader = \"\"\n\t}\n\tif cfg.RequestHashHeader != \"\" {\n\t\tcfg.RequestHashHeader = strings.ToLower(cfg.RequestHashHeader)\n\t\t// See rules in https://github.com/grpc/proposal/blob/master/A76-ring-hash-improvements.md#explicitly-setting-the-request-hash-key\n\t\tif err := metadata.ValidateKey(cfg.RequestHashHeader); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid requestHashHeader %q: %v\", cfg.RequestHashHeader, err)\n\t\t}\n\t\tif strings.HasSuffix(cfg.RequestHashHeader, \"-bin\") {\n\t\t\treturn nil, fmt.Errorf(\"invalid requestHashHeader %q: key must not end with \\\"-bin\\\"\", cfg.RequestHashHeader)","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/grpc/grpc-go/blob/0c51461d27177d997e14c642fe18c11668fc09a3/balancer/ringhash/config.go#L37-L73","documentation":"Returned by ringhash's parseConfig() (balancer/ringhash/config.go:55) when, after applying defaults (min=1024, max=4096 for zero values), MinRingSize > MaxRingSize. The ring cannot be built smaller than its minimum, so this ordering is invalid.","triggerScenarios":"The config explicitly sets minRingSize greater than maxRingSize, OR sets only maxRingSize to a value below the default min (1024). After the defaults are applied at lines 48-53, the check at line 54 fails.","commonSituations":"Operator swaps the two fields; sets minRingSize=8192 but leaves maxRingSize unset (defaults to 4096); xDS sends an inconsistent pair.","solutions":["Ensure minRingSize <= maxRingSize.","If you set minRingSize above the default max (4096), also set maxRingSize accordingly.","Omit both to use defaults (1024/4096)."],"exampleFix":"// before: min > max (max defaults to 4096)\ngrpc.WithDefaultServiceConfig(`{\"loadBalancingConfig\":[{\"ring_hash_experimental\":{\"minRingSize\":8192}}]}`)\n\n// after: min <= max\ngrpc.WithDefaultServiceConfig(`{\"loadBalancingConfig\":[{\"ring_hash_experimental\":{\"minRingSize\":8192,\"maxRingSize\":16384}}]}`)","handlingStrategy":"validation","validationCode":"func validateRingSizeOrder(min, max uint64) error {\n    // mimic defaults: 0 → default\n    if min == 0 { min = 1024 }\n    if max == 0 { max = 4096 }\n    if min > max {\n        return fmt.Errorf(\"min %d > max %d\", min, max)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When raising minRingSize above 4096, always set maxRingSize to match or exceed it.","Validate the min/max pair together in a single check."],"tags":["grpc","balancer","ringhash","config","validation","ring-size"],"backgroundTag":null,"analyzedSha":"0c51461d27177d997e14c642fe18c11668fc09a3","analyzedAt":"2026-08-11T14:49:15.055Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}