grpc/grpc-go · error
rls_csp: error marshaling load balancing config %v: %v
Error message
rls_csp: error marshaling load balancing config %v: %v
What it means
Returned when encoding/json.Marshal of the internally constructed lbConfigJSON (RouteLookupConfig raw JSON + hardcoded child policy) fails. Because all fields are built from controlled types, this is effectively an internal/programmer error and should not occur in normal operation.
Source
Thrown at internal/xds/clusterspecifier/rls/rls.go:83
return nil, fmt.Errorf("rls_csp: error parsing config %v: %v", cfg, err)
}
rlcJSON, err := protojson.Marshal(rlcs.GetRouteLookupConfig())
if err != nil {
return nil, fmt.Errorf("rls_csp: error marshaling route lookup config: %v: %v", rlcs.GetRouteLookupConfig(), err)
}
lbCfgJSON := &lbConfigJSON{
RouteLookupConfig: rlcJSON, // "JSON form of RouteLookupClusterSpecifier.config" - RLS in xDS Design Doc
ChildPolicy: []map[string]json.RawMessage{
{
"cds_experimental": json.RawMessage(`{"isDynamic":true}`),
},
},
ChildPolicyConfigTargetFieldName: "cluster",
}
rawJSON, err := json.Marshal(lbCfgJSON)
if err != nil {
return nil, fmt.Errorf("rls_csp: error marshaling load balancing config %v: %v", lbCfgJSON, err)
}
rlsBB := balancer.Get(internal.RLSLoadBalancingPolicyName)
if rlsBB == nil {
return nil, fmt.Errorf("RLS LB policy not registered")
}
if _, err = rlsBB.(balancer.ConfigParser).ParseConfig(rawJSON); err != nil {
return nil, fmt.Errorf("rls_csp: validation error from rls lb policy parsing: %v", err)
}
return clusterspecifier.BalancerConfig{{internal.RLSLoadBalancingPolicyName: lbCfgJSON}}, nil
}
View on GitHub (pinned to 03255a9237)
Solutions
- Report upstream as a bug — the constructed lbConfigJSON should always serialize.
- If forking the plugin, ensure RouteLookupConfig remains a valid json.RawMessage and childPolicy entries are valid JSON objects.
Defensive patterns
Strategy: try-catch
Prevention
- Treat this as an internal defect; do not attempt to construct lbConfigJSON yourself.
- If forking the plugin, keep RouteLookupConfig as valid json.RawMessage.
- Report upstream with the triggering config.
When it happens
Trigger: A json.RawMessage field inside lbCfgJSON containing invalid JSON, or a type that does not satisfy json.Marshaler — only possible if the hardcoded construction is tampered with or a dependency returns malformed raw JSON.
Common situations: Not seen in production through the xDS path; would indicate a bug in the RLS plugin or a corrupted build. Treat as a defect to report.
Related errors
- rls_csp: error marshaling route lookup config: %v: %v
- rls: json unmarshal failed for service config %+v: %v
- rls: json unmarshal failed for child policy config %q: %v
- rls: json marshal failed for child policy config {%+v}: %v
- xds_wrr_locality: config generated %v is invalid: %v
AI-assisted analysis of grpc/grpc-go@03255a9237 (2026-08-07).
Data as JSON: /api/errors/eeae4e1a1dca9459.
Report an issue: GitHub.