{"record":{"id":"46f87fadeb457bd1","repo":"vitessio/vitess","slug":"unsupported-balancer-policy-s-must-be-one-of-s","errorCode":null,"errorMessage":"unsupported balancer policy %s; must be one of %s","messagePattern":"unsupported balancer policy (.+?); must be one of (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtadmin/cluster/resolver/resolver.go","lineNumber":98,"sourceCode":"\nconst (\n\t// PickFirstBalancer\n\tPickFirstBalancer  BalancerPolicy = \"pick_first\"\n\tRoundRobinBalancer BalancerPolicy = \"round_robin\"\n)\n\nvar allBalancerPolicies = []string{ // convenience for help/error messages\n\tstring(PickFirstBalancer),\n\tstring(RoundRobinBalancer),\n}\n\n// Set is part of the pflag.Value interface.\nfunc (bp *BalancerPolicy) Set(s string) error {\n\tswitch s {\n\tcase string(PickFirstBalancer), string(RoundRobinBalancer):\n\t\t*bp = BalancerPolicy(s)\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported balancer policy %s; must be one of %s\", s, strings.Join(allBalancerPolicies, \", \"))\n\t}\n\n\treturn nil\n}\n\n// String is part of the pflag.Value interface.\nfunc (bp *BalancerPolicy) String() string { return string(*bp) }\n\n// Type is part of the pflag.Value interface.\nfunc (*BalancerPolicy) Type() string { return \"resolver.BalancerPolicy\" }\n\n// Options defines the configuration options that can produce a resolver.Builder.\n//\n// A builder may be produced directly from an Options struct, but the intended\n// usage is to first initialize an Options struct via opts.InstallFlags, which\n// ensures the Options have sensible defaults and both vtctldclient proxy and\n// VTGateProxy do.\ntype Options struct {","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtadmin/cluster/resolver/resolver.go#L80-L116","documentation":"BalancerPolicy implements pflag.Value; Set validates the string and rejects anything other than the registered policies (pickfirst or round_robin). The error lists the valid options via allBalancerPolicies. It is thrown at flag/config parsing time, before any gRPC connection is attempted, so the process fails fast with an actionable message.","triggerScenarios":"Passing --grpc-resolver-balancer-policy (or setting BalancerPolicy via config/API) with a value like \"roundrobin\", \"least_request\", or a misspelled policy to resolver BalancerPolicy.Set, or embedding it in a cluster config that is unmarshaled through the flag interface.","commonSituations":"Developers copying gRPC load-balancing policy names from general gRPC docs (e.g. 'ring_hash', 'weighted_target') that this resolver does not register; typos like 'round-robin' vs the exact registered string.","solutions":["Use exactly one of the supported values listed in the error (pickfirst or round_robin).","Check strings.Join(allBalancerPolicies, \", \") output / resolver source for canonical casing.","Remove the policy setting entirely to fall back to gRPC's default balancer.","If another policy is needed, register it in the resolver before use (code change)."],"exampleFix":"// before\nbp.Set(\"round-robin\")\n// after\nbp.Set(\"round_robin\")","handlingStrategy":"validation","validationCode":"func validBalancerPolicy(s string) bool {\n  return s == string(resolver.PickFirstBalancer) || s == string(resolver.RoundRobinBalancer)\n}\nif !validBalancerPolicy(policy) {\n  return fmt.Errorf(\"policy %q unsupported\", policy)\n}","typeGuard":"func isBalancerPolicy(s string) (resolver.BalancerPolicy, bool) {\n  bp := resolver.BalancerPolicy(s)\n  return bp, bp.Set(s) == nil\n}","tryCatchPattern":"bp := resolver.BalancerPolicy(cfg.Policy)\nif err := bp.Set(cfg.Policy); err != nil {\n  log.Warn(\"falling back to default balancer\", slog.Any(\"error\", err))\n  bp = \"\"\n}","preventionTips":["Only use values printed by the error message (allBalancerPolicies).","Validate policy strings at config-load time, before flag parsing surfaces it.","Don't copy arbitrary gRPC LB policy names — this resolver registers a limited set.","Add a config schema test enumerating allowed values."],"tags":["config","grpc","validation","flag-parsing"],"backgroundTag":"invalid-enum-value","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}