{"record":{"id":"eeae4e1a1dca9459","repo":"grpc/grpc-go","slug":"rls-csp-error-marshaling-load-balancing-config-v","errorCode":null,"errorMessage":"rls_csp: error marshaling load balancing config %v: %v","messagePattern":"rls_csp: error marshaling load balancing config (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/xds/clusterspecifier/rls/rls.go","lineNumber":83,"sourceCode":"\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)\n\t}\n\n\trlsBB := balancer.Get(internal.RLSLoadBalancingPolicyName)\n\tif rlsBB == nil {\n\t\treturn nil, fmt.Errorf(\"RLS LB policy not registered\")\n\t}\n\tif _, err = rlsBB.(balancer.ConfigParser).ParseConfig(rawJSON); err != nil {\n\t\treturn nil, fmt.Errorf(\"rls_csp: validation error from rls lb policy parsing: %v\", err)\n\t}\n\n\treturn clusterspecifier.BalancerConfig{{internal.RLSLoadBalancingPolicyName: lbCfgJSON}}, nil\n}\n","sourceCodeStart":65,"sourceCodeEnd":96,"githubUrl":"https://github.com/grpc/grpc-go/blob/03255a9237b6eb32710f6bc4f2de9a675b99fe36/internal/xds/clusterspecifier/rls/rls.go#L65-L96","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["grpc","xds","rls","json","internal"],"analyzedSha":"03255a9237b6eb32710f6bc4f2de9a675b99fe36","analyzedAt":"2026-08-07T00:29:34.215Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}