grpc/grpc-go · error
error parsing config for policy %q: %v
Error message
error parsing config for policy %q: %v
What it means
Returned by gracefulswitch.ParseConfig when the child balancer's ConfigParser.ParseConfig rejects the config JSON. The gracefulswitch parser found a registered builder for the policy name (config.go:64-68) and confirmed it implements balancer.ConfigParser (config.go:70-74), but the builder's own parser returned an error. The %q is the policy name; %v is the underlying parse error from the child.
Source
Thrown at internal/balancer/gracefulswitch/config.go:78
var jsonCfg json.RawMessage
for name, jsonCfg = range e {
}
builder := balancer.Get(name)
if builder == nil {
// Skip unregistered balancer names.
continue
}
parser, ok := builder.(balancer.ConfigParser)
if !ok {
// This is a valid child with no config.
return &lbConfig{childBuilder: builder}, nil
}
cfg, err := parser.ParseConfig(jsonCfg)
if err != nil {
return nil, fmt.Errorf("error parsing config for policy %q: %v", name, err)
}
return &lbConfig{childBuilder: builder, childConfig: cfg}, nil
}
return nil, fmt.Errorf("no supported policies found in config: %v", string(cfg))
}
View on GitHub (pinned to 0c51461d27)
Solutions
- Inspect the wrapped error (%v) to identify which field or value the child parser rejected
- Compare your config JSON against the child balancer's expected config struct definition for your gRPC version
- Ensure the gRPC version that generated the service config matches the version running in the client
- Test the child config in isolation by calling the specific balancer's ParseConfig directly
Example fix
// before: weighted_round_robin with invalid child config
{"loadBalancingConfig": [{"weighted_round_robin": {"children": {"child-0": {"weight": "not-a-number"}}}}]}
// after: correct numeric weight
{"loadBalancingConfig": [{"weighted_round_robin": {"children": {"child-0": {"weight": 1}}}}]} Defensive patterns
Strategy: validation
Validate before calling
// Validate child config by testing the specific balancer's parser in isolation
func validateChildConfig(policyName string, childCfg json.RawMessage) error {
builder := balancer.Get(policyName)
if builder == nil {
return fmt.Errorf("balancer %q not registered", policyName)
}
parser, ok := builder.(balancer.ConfigParser)
if !ok {
return nil // no config to validate
}
_, err := parser.ParseConfig(childCfg)
return err
} Try / catch
// When calling ParseConfig, inspect the wrapped error for child-specific details
cfg, err := gracefulswitch.ParseConfig(rawCfg)
if err != nil {
// Check if this is a child parse error (contains 'error parsing config for policy')
if strings.Contains(err.Error(), "error parsing config for policy") {
// Extract the policy name and underlying cause for targeted fix
log.Printf("child balancer config invalid: %v", err)
}
return err
} Prevention
- Pin your gRPC version so the service config schema matches the running code
- Test child balancer configs in isolation using the specific balancer's ParseConfig
- Use integration tests that exercise the full service config parsing path
When it happens
Trigger: Passing a loadBalancingConfig entry whose inner config JSON is invalid for the named policy. For example, a weighted_round_robin config with invalid child field types, or a priority config referencing unknown child policies. The error surfaces through gracefulswitch.ParseConfig -> parser.ParseConfig at config.go:76-78.
Common situations: Version mismatch between the service config JSON schema and the installed gRPC version. A config generated for a newer balancer that expects different field names or types. Typos in config field names that the child parser strictly validates.
Related errors
- expected a JSON struct with one entry; received entry %v at
- no supported policies found in config: %v
- least-request: unable to unmarshal LBConfig: %v
- least-request: lbConfig.choiceCount: %v, must be >= 2
- pickfirst: unable to unmarshal LB policy config: %s, error:
AI-assisted analysis of grpc/grpc-go@0c51461d27 (2026-08-11).
Data as JSON: /api/errors/1de96bf3f9abf1e9.
Report an issue: GitHub.