grpc/grpc-go · error
xds_wrr_locality: invalid LBConfig: %s, error: %v
Error message
xds_wrr_locality: invalid LBConfig: %s, error: %v
What it means
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.
Source
Thrown at internal/xds/balancer/wrrlocality/balancer.go:95
wtbCfgParser, ok := builder.(balancer.ConfigParser)
if !ok {
// Shouldn't happen, imported weighted target builder has this method.
return nil
}
wrrL := &wrrLocalityBalancer{
child: wtb,
childParser: wtbCfgParser,
}
wrrL.logger = prefixLogger(wrrL)
wrrL.logger.Infof("Created")
return wrrL
}
func (bb) ParseConfig(s json.RawMessage) (serviceconfig.LoadBalancingConfig, error) {
var lbCfg *LBConfig
if err := json.Unmarshal(s, &lbCfg); err != nil {
return nil, fmt.Errorf("xds_wrr_locality: invalid LBConfig: %s, error: %v", string(s), err)
}
if lbCfg == nil || lbCfg.ChildPolicy == nil {
return nil, errors.New("xds_wrr_locality: invalid LBConfig: child policy field must be set")
}
return lbCfg, nil
}
type attributeKey struct{}
// Equal allows the values to be compared by Attributes.Equal.
func (a AddrInfo) Equal(o any) bool {
oa, ok := o.(AddrInfo)
return ok && oa.LocalityWeight == a.LocalityWeight
}
// AddrInfo is the locality weight of the locality an address is a part of.
type AddrInfo struct {
LocalityWeight uint32View on GitHub (pinned to 03255a9237)
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
Example fix
// before
{"childPolicy":"round_robin"} // string, not a config object
// after
{"childPolicy":[{"round_robin":{}}]} Defensive patterns
Strategy: validation
Validate before calling
// Reject malformed JSON before ParseConfig.
if !json.Valid(raw) {
return fmt.Errorf("wrr_locality config is not valid JSON: %s", string(raw))
} Type guard
func isWrrLocalityConfig(raw json.RawMessage) bool {
var probe struct{ ChildPolicy json.RawMessage `json:"childPolicy"` }
return json.Unmarshal(raw, &probe) == nil && probe.ChildPolicy != nil
} Try / catch
cfg, err := wrrLocalityBB.ParseConfig(raw)
if err != nil {
logger.Warningf("rejecting wrr_locality config: %v", err)
return fallbackLBConfig
} Prevention
- Validate JSON syntax upstream
- Ensure childPolicy is a config object, not a bare string
When it happens
Trigger: 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.
Common situations: Control plane sends a corrupt Cluster config; hand-built service config with a JSON typo; version skew where the config shape changed.
Related errors
- OutlierDetectionLoadBalancingConfig.interval = %s; must be >
- OutlierDetectionLoadBalancingConfig.base_ejection_time = %s;
- OutlierDetectionLoadBalancingConfig.max_ejection_time = %s;
- OutlierDetectionLoadBalancingConfig.max_ejection_percent = %
- OutlierDetectionLoadBalancingConfig.SuccessRateEjection.enfo
AI-assisted analysis of grpc/grpc-go@03255a9237 (2026-08-07).
Data as JSON: /api/errors/82a9469e07d62437.
Report an issue: GitHub.