{"record":{"id":"df2b7e46195eb861","repo":"grpc/grpc-go","slug":"rls-csp-error-parsing-config-v-unknown-type-t","errorCode":null,"errorMessage":"rls_csp: error parsing config %v: unknown type %T","messagePattern":"rls_csp: error parsing config (.+?): unknown type %T","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/xds/clusterspecifier/rls/rls.go","lineNumber":60,"sourceCode":"\treturn []string{\"type.googleapis.com/grpc.lookup.v1.RouteLookupClusterSpecifier\"}\n}\n\n// lbConfigJSON is the RLS LB Policies configuration in JSON format.\n// RouteLookupConfig will be a raw JSON string from the passed in proto\n// 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\",","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/grpc/grpc-go/blob/03255a9237b6eb32710f6bc4f2de9a675b99fe36/internal/xds/clusterspecifier/rls/rls.go#L42-L78","documentation":"Returned by ParseClusterSpecifierConfig when cfg is non-nil but not a *anypb.Any. The clusterspecifier framework always wraps configs as *anypb.Any, so reaching this branch means the framework or a custom caller bypassed that contract.","triggerScenarios":"A direct call to ParseClusterSpecifierConfig with a concrete proto type (e.g. *rlspb.RouteLookupClusterSpecifier) instead of *anypb.Any, or a framework integration bug that does not Any-wrap.","commonSituations":"Unit tests or custom clusterspecifier plumbing that invoke the parser directly with a raw proto; normal xDS-driven parsing always supplies *anypb.Any.","solutions":["When calling ParseClusterSpecifierConfig directly, wrap the proto with anypb.New first.","If this surfaces through the normal xDS path, it is a framework bug — report it with the resource that triggered it."],"exampleFix":"// before\nb, err := rls{}.ParseClusterSpecifierConfig(rlcs) // *RouteLookupClusterSpecifier\n\n// after\nany, _ := anypb.New(rlcs)\nb, err := rls{}.ParseClusterSpecifierConfig(any)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func isAnyProto(m proto.Message) (*anypb.Any, bool) {\n    a, ok := m.(*anypb.Any)\n    return a, ok\n}","tryCatchPattern":null,"preventionTips":["Always wrap configs in *anypb.Any before passing to clusterspecifier parsers.","Let the framework Any-wrap; avoid calling ParseClusterSpecifierConfig with raw protos.","Add a type assertion in test helpers to fail fast on misuse."],"tags":["grpc","xds","rls","cluster-specifier","type-error"],"analyzedSha":"03255a9237b6eb32710f6bc4f2de9a675b99fe36","analyzedAt":"2026-08-07T00:29:34.215Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}