{"record":{"id":"bb9a70db77960076","repo":"grpc/grpc-go","slug":"rls-csp-error-parsing-config-v-v","errorCode":null,"errorMessage":"rls_csp: error parsing config %v: %v","messagePattern":"rls_csp: error parsing config (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/xds/clusterspecifier/rls/rls.go","lineNumber":65,"sourceCode":"// configuration, and the other fields will be hardcoded.\ntype lbConfigJSON struct {\n\tRouteLookupConfig                json.RawMessage              `json:\"routeLookupConfig\"`\n\tChildPolicy                      []map[string]json.RawMessage `json:\"childPolicy\"`\n\tChildPolicyConfigTargetFieldName string                       `json:\"childPolicyConfigTargetFieldName\"`\n}\n\nfunc (rls) ParseClusterSpecifierConfig(cfg proto.Message) (clusterspecifier.BalancerConfig, error) {\n\tif cfg == nil {\n\t\treturn nil, fmt.Errorf(\"rls_csp: nil configuration message provided\")\n\t}\n\tm, ok := cfg.(*anypb.Any)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"rls_csp: error parsing config %v: unknown type %T\", cfg, cfg)\n\t}\n\trlcs := new(rlspb.RouteLookupClusterSpecifier)\n\n\tif err := m.UnmarshalTo(rlcs); err != nil {\n\t\treturn nil, fmt.Errorf(\"rls_csp: error parsing config %v: %v\", cfg, err)\n\t}\n\trlcJSON, err := protojson.Marshal(rlcs.GetRouteLookupConfig())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"rls_csp: error marshaling route lookup config: %v: %v\", rlcs.GetRouteLookupConfig(), err)\n\t}\n\tlbCfgJSON := &lbConfigJSON{\n\t\tRouteLookupConfig: rlcJSON, // \"JSON form of RouteLookupClusterSpecifier.config\" - RLS in xDS Design Doc\n\t\tChildPolicy: []map[string]json.RawMessage{\n\t\t\t{\n\t\t\t\t\"cds_experimental\": json.RawMessage(`{\"isDynamic\":true}`),\n\t\t\t},\n\t\t},\n\t\tChildPolicyConfigTargetFieldName: \"cluster\",\n\t}\n\n\trawJSON, err := json.Marshal(lbCfgJSON)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"rls_csp: error marshaling load balancing config %v: %v\", lbCfgJSON, err)","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/grpc/grpc-go/blob/0c51461d27177d997e14c642fe18c11668fc09a3/internal/xds/clusterspecifier/rls/rls.go#L47-L83","documentation":"The Any-wrapped configuration could not be unmarshaled into a RouteLookupClusterSpecifier proto (rls.go:64-65). The serialized bytes in the Any message do not match the grpc.lookup.v1.RouteLookupClusterSpecifier schema, or the TypeURL is incorrect.","triggerScenarios":"anypb.Any.UnmarshalTo(rlcs) fails because the Any payload is corrupted, truncated, or the TypeURL does not match 'type.googleapis.com/grpc.lookup.v1.RouteLookupClusterSpecifier'.","commonSituations":"xDS server proto version mismatch (server uses a newer or older RLS proto revision); TypeURL in the Any does not match the expected RLS type URL; network-level payload corruption; xDS server sends a different proto type under the RLS type URL.","solutions":["Verify the TypeURL in the Any matches 'type.googleapis.com/grpc.lookup.v1.RouteLookupClusterSpecifier'","Ensure the xDS server and gRPC client use compatible RLS proto versions","Check xDS transport logs for payload corruption indicators","Use an xDS config dump to inspect the raw Any payload bytes and TypeURL"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate the TypeURL before attempting to unmarshal.\nconst rlsTypeURL = \"type.googleapis.com/grpc.lookup.v1.RouteLookupClusterSpecifier\"\nif anyMsg.TypeUrl != rlsTypeURL {\n    return fmt.Errorf(\"unexpected TypeURL %q, want %q\", anyMsg.TypeUrl, rlsTypeURL)\n}","typeGuard":null,"tryCatchPattern":"result, err := plugin.ParseClusterSpecifierConfig(anyCfg)\nif err != nil && strings.Contains(err.Error(), \"error parsing config\") {\n    log.Printf(\"RLS config unmarshal failed — likely TypeURL or proto version mismatch: %v\", err)\n}","preventionTips":["Keep gRPC client and xDS server RLS proto versions in sync","Validate TypeURLs in xDS resource processors before dispatching to plugins","Use xDS config dump to inspect raw Any payloads for version mismatches"],"tags":["rls","xds","cluster-specifier","protobuf","unmarshal"],"backgroundTag":null,"analyzedSha":"0c51461d27177d997e14c642fe18c11668fc09a3","analyzedAt":"2026-08-11T14:49:15.055Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}