grpc/grpc-go · error

rls_csp: error marshaling route lookup config

Error message

rls_csp: error marshaling route lookup config: %v: %v

What it means

After successfully unmarshaling the RouteLookupClusterSpecifier, the embedded RouteLookupConfig sub-message could not be serialized to JSON via protojson.Marshal (rls.go:67-69). This typically means RouteLookupConfig is nil or contains data that violates protojson serialization invariants.

Solutions

  1. Ensure the xDS server always includes a non-nil RouteLookupConfig in the RouteLookupClusterSpecifier
  2. Validate the RouteLookupConfig proto for completeness before deploying the xDS config
  3. Check for proto version differences in the RouteLookupConfig schema
Defensive patterns

Strategy: validation

Validate before calling

// Verify RouteLookupConfig is non-nil before processing.
rlcs := new(rlspb.RouteLookupClusterSpecifier)
_ = anyMsg.UnmarshalTo(rlcs)
if rlcs.GetRouteLookupConfig() == nil {
    return fmt.Errorf("RouteLookupClusterSpecifier must include a non-nil RouteLookupConfig")
}

Prevention

When it happens

Trigger: rlcs.GetRouteLookupConfig() returns nil or an invalid proto, causing protojson.Marshal to fail when converting the RouteLookupConfig to the JSON form needed for the LB policy configuration.

Common situations: xDS server sends a RouteLookupClusterSpecifier with a nil RouteLookupConfig field; required sub-fields of RouteLookupConfig are missing or invalid; proto version differences in the RouteLookupConfig schema between server and client.

Related errors


AI-assisted analysis of grpc/grpc-go@0c51461d27 (2026-08-11). Data as JSON: /api/errors/837cec548d6c9b67. Report an issue: GitHub.

Appendix: source

Thrown at internal/xds/clusterspecifier/rls/rls.go:69

	ChildPolicyConfigTargetFieldName string                       `json:"childPolicyConfigTargetFieldName"`
}

func (rls) ParseClusterSpecifierConfig(cfg proto.Message) (clusterspecifier.BalancerConfig, error) {
	if cfg == nil {
		return nil, fmt.Errorf("rls_csp: nil configuration message provided")
	}
	m, ok := cfg.(*anypb.Any)
	if !ok {
		return nil, fmt.Errorf("rls_csp: error parsing config %v: unknown type %T", cfg, cfg)
	}
	rlcs := new(rlspb.RouteLookupClusterSpecifier)

	if err := m.UnmarshalTo(rlcs); err != nil {
		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 {

View on GitHub (pinned to 0c51461d27)