{"record":{"id":"ecb1e3dc29e6028f","repo":"grpc/grpc-go","slug":"error-parsing-loadbalancingconfig-for-policy-q","errorCode":null,"errorMessage":"error parsing loadBalancingConfig for policy %q: %v","messagePattern":"error parsing loadBalancingConfig for policy %q: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/serviceconfig/serviceconfig.go","lineNumber":116,"sourceCode":"\t\tif builder == nil {\n\t\t\t// If the balancer is not registered, move on to the next config.\n\t\t\t// This is not an error.\n\t\t\tcontinue\n\t\t}\n\t\tbc.Name = name\n\n\t\tparser, ok := builder.(balancer.ConfigParser)\n\t\tif !ok {\n\t\t\tif string(jsonCfg) != \"{}\" {\n\t\t\t\tlogger.Warningf(\"non-empty balancer configuration %q, but balancer does not implement ParseConfig\", string(jsonCfg))\n\t\t\t}\n\t\t\t// Stop at this, though the builder doesn't support parsing config.\n\t\t\treturn nil\n\t\t}\n\n\t\tcfg, err := parser.ParseConfig(jsonCfg)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error parsing loadBalancingConfig for policy %q: %v\", name, err)\n\t\t}\n\t\tbc.Config = cfg\n\t\treturn nil\n\t}\n\t// This is reached when the for loop iterates over all entries, but didn't\n\t// return. This means we had a loadBalancingConfig slice but did not\n\t// encounter a registered policy. The config is considered invalid in this\n\t// case.\n\treturn fmt.Errorf(\"invalid loadBalancingConfig: no supported policies found in %v\", names)\n}\n\n// MethodConfig defines the configuration recommended by the service providers for a\n// particular method.\ntype MethodConfig struct {\n\t// WaitForReady indicates whether RPCs sent to this method should wait until\n\t// the connection is ready by default (!failfast). The value specified via the\n\t// gRPC client API will override the value set here.\n\tWaitForReady *bool","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/grpc/grpc-go/blob/03255a9237b6eb32710f6bc4f2de9a675b99fe36/internal/serviceconfig/serviceconfig.go#L98-L134","documentation":"This error occurs when a registered load balancing policy's ConfigParser.ParseConfig rejects the provided JSON config. The balancer was found in the registry, but its custom parsing logic flagged the config as invalid for that specific policy (e.g., bad field values for round_robin, weighted_target, or rls).","triggerScenarios":"A service config loadBalancingConfig entry references a registered balancer (e.g., \"weighted_target\") but the config JSON for that balancer is structurally invalid per its own ParseConfig implementation — for example, negative weights, missing required fields, or malformed sub-configs.","commonSituations":"xDS control plane emits a balancer config with wrong field types or values, version mismatch between the control plane config schema and the gRPC client library (newer config format sent to older client), or custom balancer with strict parsing rejecting unexpected fields.","solutions":["Check the inner error (%v) to identify which field/value the balancer rejected.","Align the balancer config JSON with the schema expected by the registered balancer version in your client.","Upgrade or downgrade the gRPC client to match the config format emitted by your control plane.","If using a custom balancer, review its ParseConfig for the validation rule that triggered the error."],"exampleFix":"// before (broken): weighted_target with invalid child config\n{\"weighted_target\": {\"targets\": {\"a\": {\"weight\": -1, \"childPolicy\": [{}]}}}}\n\n// after (valid): non-negative weight\n{\"weighted_target\": {\"targets\": {\"a\": {\"weight\": 1, \"childPolicy\": [{\"pick_first\": {}}]}}}}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"var bc serviceconfig.BalancerConfig\nif err := json.Unmarshal(raw, &bc); err != nil {\n    if strings.Contains(err.Error(), \"error parsing loadBalancingConfig\") {\n        // log inner error, check balancer version compatibility\n        log.Printf(\"balancer config parse failed: %v — check policy %q schema\", err, bc.Name)\n        return nil // skip applying this config\n    }\n    return err\n}","preventionTips":["Keep client gRPC version in sync with the balancer config schema version.","Test balancer configs against the exact client library version in production.","Import only the balancers you need and verify their config schemas in documentation."],"tags":["service-config","load-balancing","balancer","configuration","xds"],"analyzedSha":"03255a9237b6eb32710f6bc4f2de9a675b99fe36","analyzedAt":"2026-08-07T00:29:34.215Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}