{"record":{"id":"50525c786926ac6f","repo":"grpc/grpc-go","slug":"xds-wrr-locality-config-generated-v-is-invalid","errorCode":null,"errorMessage":"xds_wrr_locality: config generated %v is invalid: %v","messagePattern":"xds_wrr_locality: config generated (.+?) is invalid: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/xds/balancer/wrrlocality/balancer.go","lineNumber":182,"sourceCode":"\t\t// shouldn't happen though (this attribute that is set actually gets\n\t\t// used to build localities in the first place), and thus don't error\n\t\t// out, and just build a weighted target with undefined behavior.\n\t\tlocality := xdsinternal.LocalityString(xdsinternal.LocalityIDFromEndpoint(ep))\n\t\tai, ok := getAddrInfo(ep)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"xds_wrr_locality: missing locality weight information in endpoint %q\", ep)\n\t\t}\n\t\tweightedTargets[locality] = weightedtarget.Target{Weight: ai.LocalityWeight, ChildPolicy: lbCfg.ChildPolicy}\n\t}\n\twtCfg := &weightedtarget.LBConfig{Targets: weightedTargets}\n\twtCfgJSON, err := json.Marshal(wtCfg)\n\tif err != nil {\n\t\t// Shouldn't happen.\n\t\treturn fmt.Errorf(\"xds_wrr_locality: error marshalling prepared config: %v\", wtCfg)\n\t}\n\tvar sc serviceconfig.LoadBalancingConfig\n\tif sc, err = b.childParser.ParseConfig(wtCfgJSON); err != nil {\n\t\treturn fmt.Errorf(\"xds_wrr_locality: config generated %v is invalid: %v\", wtCfgJSON, err)\n\t}\n\n\treturn b.child.UpdateClientConnState(balancer.ClientConnState{\n\t\tResolverState:  s.ResolverState,\n\t\tBalancerConfig: sc,\n\t})\n}\n\nfunc (b *wrrLocalityBalancer) ResolverError(err error) {\n\tb.child.ResolverError(err)\n}\n\nfunc (b *wrrLocalityBalancer) UpdateSubConnState(sc balancer.SubConn, state balancer.SubConnState) {\n\tb.logger.Errorf(\"UpdateSubConnState(%v, %+v) called unexpectedly\", sc, state)\n}\n\nfunc (b *wrrLocalityBalancer) Close() {\n\tb.child.Close()","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/grpc/grpc-go/blob/0c51461d27177d997e14c642fe18c11668fc09a3/internal/xds/balancer/wrrlocality/balancer.go#L164-L200","documentation":"Returned when the weighted-target child balancer's ConfigParser rejects the config that wrr_locality generated from locality weights and the configured child policy. The generated weighted target JSON is logged so you can see exactly what was rejected.","triggerScenarios":"Triggered at balancer.go:182 when b.childParser.ParseConfig(wtCfgJSON) (the weighted_target parser) returns an error. Root cause is usually an invalid or unregistered childPolicy inside the wrr_locality LBConfig.","commonSituations":"The childPolicy named in the wrr_locality config is not a registered balancer (typo, e.g. 'wrr' instead of 'weighted_round_robin'); the child policy requires config fields that were not supplied; grpc-go version that does not register the requested policy.","solutions":["Read the nested child-parser error (the second %v) to identify which childPolicy failed.","Ensure the named child balancer is registered: import the balancer package (e.g. _ \"google.golang.org/grpc/balancer/weightedroundrobin\") or use a built-in like round_robin.","Correct the childPolicy entry in the xDS/LB config to a registered, correctly-shaped policy.","Upgrade grpc-go if the policy is supported only in a newer version."],"exampleFix":"// before: childPolicy references an unregistered balancer\n{\"childPolicy\":[{\"wrr\":{}}]}\n\n// after: use a registered balancer\n{\"childPolicy\":[{\"round_robin\":{}}]}","handlingStrategy":"validation","validationCode":"// Confirm the childPolicy names a registered balancer before publishing config.\nfunc childPolicyRegistered(name string) bool {\n    return balancer.Get(name) != nil\n}","typeGuard":null,"tryCatchPattern":"// The nested child-parser error is wrapped; inspect it.\nif err := b.UpdateClientConnState(s); err != nil {\n    if strings.Contains(err.Error(), \"config generated\") {\n        // pull the nested cause and fix the childPolicy block.\n    }\n}","preventionTips":["Import side-effect packages for any non-default balancers you reference.","Use canonical balancer names (round_robin, weighted_round_robin, pick_first).","Test the service config against the running client before rolling out."],"tags":["grpc","xds","balancer","wrr-locality","weighted-target","config","go"],"backgroundTag":null,"analyzedSha":"0c51461d27177d997e14c642fe18c11668fc09a3","analyzedAt":"2026-08-11T14:49:15.055Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}