{"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/03255a9237b6eb32710f6bc4f2de9a675b99fe36/internal/xds/balancer/wrrlocality/balancer.go#L164-L200","documentation":"Returned by wrr_locality UpdateClientConnState (internal/xds/balancer/wrrlocality/balancer.go:182) when the weighted-target config it generated from the endpoints/weights fails to parse via the child parser. This is an internal invariant violation — the generated config should always be valid — so it generally indicates a bug or an endpoint with an invalid locality string.","triggerScenarios":"UpdateClientConnState builds weightedTargets from endpoints, marshals it to JSON, and the weighted_target parser rejects it. Only reachable if a generated weight/target combination is invalid.","commonSituations":"A zero or overflowing locality weight; an internal version mismatch between wrrlocality and weightedtarget; effectively never seen in production — treat as a bug report candidate.","solutions":["Inspect the underlying error (%v) to see which target/weight the child parser rejected","Verify endpoint locality weights are sane non-zero values","Report it upstream if it reproduces with a valid xDS resolver state"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := bal.UpdateClientConnState(state); err != nil {\n    if strings.Contains(err.Error(), \"config generated\") {\n        logger.Errorf(\"internal wrr_locality invariant violated; report upstream: %v\", err)\n    }\n    return err\n}","preventionTips":["Treat this as a bug — collect the endpoint set and weights and report it","Keep wrrlocality and weightedtarget versions in sync"],"tags":["grpc","xds","wrr-locality","load-balancing","internal","go"],"analyzedSha":"03255a9237b6eb32710f6bc4f2de9a675b99fe36","analyzedAt":"2026-08-07T00:29:34.215Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}