grpc/grpc-go · error
xds_wrr_locality: missing locality weight information in end
Error message
xds_wrr_locality: missing locality weight information in endpoint %q
What it means
Returned by wrr_locality UpdateClientConnState (internal/xds/balancer/wrrlocality/balancer.go:170) when an endpoint in the resolver state has no AddrInfo attribute (no locality weight). The xDS resolver normally attaches AddrInfo with the locality weight to every endpoint; wrr_locality needs it to build weighted targets per locality.
Source
Thrown at internal/xds/balancer/wrrlocality/balancer.go:170
}
func (b *wrrLocalityBalancer) UpdateClientConnState(s balancer.ClientConnState) error {
lbCfg, ok := s.BalancerConfig.(*LBConfig)
if !ok {
b.logger.Errorf("Received config with unexpected type %T: %v", s.BalancerConfig, s.BalancerConfig)
return balancer.ErrBadResolverState
}
weightedTargets := make(map[string]weightedtarget.Target)
for _, ep := range s.ResolverState.Endpoints {
// This get of LocalityID could potentially return a zero value. This
// shouldn't happen though (this attribute that is set actually gets
// used to build localities in the first place), and thus don't error
// out, and just build a weighted target with undefined behavior.
locality := xdsinternal.LocalityString(xdsinternal.LocalityIDFromEndpoint(ep))
ai, ok := getAddrInfo(ep)
if !ok {
return fmt.Errorf("xds_wrr_locality: missing locality weight information in endpoint %q", ep)
}
weightedTargets[locality] = weightedtarget.Target{Weight: ai.LocalityWeight, ChildPolicy: lbCfg.ChildPolicy}
}
wtCfg := &weightedtarget.LBConfig{Targets: weightedTargets}
wtCfgJSON, err := json.Marshal(wtCfg)
if err != nil {
// Shouldn't happen.
return fmt.Errorf("xds_wrr_locality: error marshalling prepared config: %v", wtCfg)
}
var sc serviceconfig.LoadBalancingConfig
if sc, err = b.childParser.ParseConfig(wtCfgJSON); err != nil {
return fmt.Errorf("xds_wrr_locality: config generated %v is invalid: %v", wtCfgJSON, err)
}
return b.child.UpdateClientConnState(balancer.ClientConnState{
ResolverState: s.ResolverState,
BalancerConfig: sc,
})View on GitHub (pinned to 03255a9237)
Solutions
- Ensure the channel is driven by the xDS resolver so endpoints carry AddrInfo
- If building endpoints manually, attach the weight via wrrlocality.SetAddrInfo(ep, AddrInfo{LocalityWeight: w})
- Use wrr_locality only within the xDS-managed path
Example fix
// before: endpoint built without locality weight
ep := resolver.Endpoint{...}
// after
import "google.golang.org/grpc/internal/xds/balancer/wrrlocality"
ep := wrrlocality.SetAddrInfo(resolver.Endpoint{...}, wrrlocality.AddrInfo{LocalityWeight: 100}) Defensive patterns
Strategy: validation
Validate before calling
// Ensure every endpoint carries a locality weight before UpdateClientConnState.
for _, ep := range state.ResolverState.Endpoints {
if _, ok := wrrlocality.GetAddrInfoPublic(ep); !ok {
return fmt.Errorf("endpoint missing locality weight; not from xDS resolver")
}
} Type guard
func endpointsHaveLocalityWeight(eps []resolver.Endpoint) bool {
for _, ep := range eps {
v := ep.Attributes.Value(attributeKey{})
if _, ok := v.(wrrlocality.AddrInfo); !ok {
return false
}
}
return true
} Try / catch
if err := bal.UpdateClientConnState(state); err != nil {
if strings.Contains(err.Error(), "missing locality weight") {
logger.Errorf("endpoints not produced by xDS resolver; skip wrr_locality: %v", err)
}
return err
} Prevention
- Use wrr_locality only behind the xDS resolver
- When constructing endpoints manually, call wrrlocality.SetAddrInfo
- In tests, always attach AddrInfo to fake endpoints
When it happens
Trigger: UpdateClientConnState iterates endpoints and getAddrInfo(ep) returns ok=false for one of them, meaning the resolver did not call SetAddrInfo to attach a LocalityWeight attribute. This should not happen in the real xDS flow; it indicates the resolver state was not produced by the xDS resolver.
Common situations: A non-xDS resolver feeds endpoints into a channel using the wrr_locality policy; the xDS resolver was bypassed or a custom resolver omitted the locality weight attribute; a partially-mocked resolver in tests.
Related errors
- xds_wrr_locality: invalid LBConfig: %s, error: %v
- xds_wrr_locality: config generated %v is invalid: %v
- endpoints list is empty
- endpoints list contains no addresses
- ringhash: expected xDS config selector to set the request ha
AI-assisted analysis of grpc/grpc-go@03255a9237 (2026-08-07).
Data as JSON: /api/errors/d48f695305c7d713.
Report an issue: GitHub.