{"record":{"id":"82a9469e07d62437","repo":"grpc/grpc-go","slug":"xds-wrr-locality-invalid-lbconfig-s-error-v","errorCode":null,"errorMessage":"xds_wrr_locality: invalid LBConfig: %s, error: %v","messagePattern":"xds_wrr_locality: invalid LBConfig: (.+?), error: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/xds/balancer/wrrlocality/balancer.go","lineNumber":95,"sourceCode":"\twtbCfgParser, ok := builder.(balancer.ConfigParser)\n\tif !ok {\n\t\t// Shouldn't happen, imported weighted target builder has this method.\n\t\treturn nil\n\t}\n\twrrL := &wrrLocalityBalancer{\n\t\tchild:       wtb,\n\t\tchildParser: wtbCfgParser,\n\t}\n\n\twrrL.logger = prefixLogger(wrrL)\n\twrrL.logger.Infof(\"Created\")\n\treturn wrrL\n}\n\nfunc (bb) ParseConfig(s json.RawMessage) (serviceconfig.LoadBalancingConfig, error) {\n\tvar lbCfg *LBConfig\n\tif err := json.Unmarshal(s, &lbCfg); err != nil {\n\t\treturn nil, fmt.Errorf(\"xds_wrr_locality: invalid LBConfig: %s, error: %v\", string(s), err)\n\t}\n\tif lbCfg == nil || lbCfg.ChildPolicy == nil {\n\t\treturn nil, errors.New(\"xds_wrr_locality: invalid LBConfig: child policy field must be set\")\n\t}\n\treturn lbCfg, nil\n}\n\ntype attributeKey struct{}\n\n// Equal allows the values to be compared by Attributes.Equal.\nfunc (a AddrInfo) Equal(o any) bool {\n\toa, ok := o.(AddrInfo)\n\treturn ok && oa.LocalityWeight == a.LocalityWeight\n}\n\n// AddrInfo is the locality weight of the locality an address is a part of.\ntype AddrInfo struct {\n\tLocalityWeight uint32","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/grpc/grpc-go/blob/03255a9237b6eb32710f6bc4f2de9a675b99fe36/internal/xds/balancer/wrrlocality/balancer.go#L77-L113","documentation":"Returned by the wrr_locality balancer's ParseConfig (internal/xds/balancer/wrrlocality/balancer.go:94) when json.Unmarshal of the raw LBConfig into *LBConfig fails. The most common cause is malformed JSON or a structurally invalid `childPolicy` field.","triggerScenarios":"ParseConfig is given JSON that does not unmarshal into the wrr_locality LBConfig shape — e.g. a JSON syntax error, or `childPolicy` present but not a valid BalancerConfig object.","commonSituations":"Control plane sends a corrupt Cluster config; hand-built service config with a JSON typo; version skew where the config shape changed.","solutions":["Validate the raw JSON parses before calling ParseConfig","Ensure `childPolicy` is a well-formed BalancerConfig object","Correct the upstream xDS resource emitting the malformed config"],"exampleFix":"// before\n{\"childPolicy\":\"round_robin\"}   // string, not a config object\n// after\n{\"childPolicy\":[{\"round_robin\":{}}]}","handlingStrategy":"validation","validationCode":"// Reject malformed JSON before ParseConfig.\nif !json.Valid(raw) {\n    return fmt.Errorf(\"wrr_locality config is not valid JSON: %s\", string(raw))\n}","typeGuard":"func isWrrLocalityConfig(raw json.RawMessage) bool {\n    var probe struct{ ChildPolicy json.RawMessage `json:\"childPolicy\"` }\n    return json.Unmarshal(raw, &probe) == nil && probe.ChildPolicy != nil\n}","tryCatchPattern":"cfg, err := wrrLocalityBB.ParseConfig(raw)\nif err != nil {\n    logger.Warningf(\"rejecting wrr_locality config: %v\", err)\n    return fallbackLBConfig\n}","preventionTips":["Validate JSON syntax upstream","Ensure childPolicy is a config object, not a bare string"],"tags":["grpc","xds","wrr-locality","load-balancing","config","go"],"analyzedSha":"03255a9237b6eb32710f6bc4f2de9a675b99fe36","analyzedAt":"2026-08-07T00:29:34.215Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}