{"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/0c51461d27177d997e14c642fe18c11668fc09a3/internal/xds/clusterspecifier/rls/rls.go#L42-L78","documentation":"ParseClusterSpecifierConfig expected the configuration wrapped as *anypb.Any but received a different concrete proto type (rls.go:58-60). In the xDS protocol all filter and extension configs are transported as Any-wrapped messages, so receiving a bare proto indicates an integration or protocol-layer error.","triggerScenarios":"The clusterspecifier framework dispatches to ParseClusterSpecifierConfig with a proto.Message whose concrete type is not *anypb.Any (e.g. an already-unwrapped RouteLookupClusterSpecifier passed by custom integration or test code).","commonSituations":"Custom clusterspecifier integration that unwraps Any before dispatching to the plugin; incorrect framework wiring; test code passing a bare proto instead of wrapping it in anypb.New().","solutions":["Ensure the clusterspecifier framework passes *anypb.Any to ParseClusterSpecifierConfig","Do not manually unwrap Any before calling the parser","If writing test code, wrap the proto with anypb.New() first"],"exampleFix":"// before — passing bare proto\nrlsCfg := &rlspb.RouteLookupClusterSpecifier{...}\nresult, err := rls{}.ParseClusterSpecifierConfig(rlsCfg)\n\n// after — wrap in Any first\nanyCfg, _ := anypb.New(rlsCfg)\nresult, err := rls{}.ParseClusterSpecifierConfig(anyCfg)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Ensure the config is *anypb.Any before passing to the parser.\nfunc isAnyProto(msg proto.Message) bool {\n    _, ok := msg.(*anypb.Any)\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Always pass *anypb.Any to clusterspecifier parsers — the framework handles unwrapping internally","Use anypb.New() to wrap protos in test code before calling parser methods","Do not manually unwrap Any messages before dispatching to plugin parsers"],"tags":["rls","xds","cluster-specifier","type-assertion"],"backgroundTag":null,"analyzedSha":"0c51461d27177d997e14c642fe18c11668fc09a3","analyzedAt":"2026-08-11T14:49:15.055Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}