{"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/0c51461d27177d997e14c642fe18c11668fc09a3/internal/serviceconfig/serviceconfig.go#L98-L134","documentation":"Fires at serviceconfig.go:116 when a registered balancer's ConfigParser.ParseConfig rejects the config JSON supplied for its policy in loadBalancingConfig. The wrapper preserves the policy name and the balancer's own error, so this is the inner balancer (e.g. weighted_round_robin, xds) saying its config block is invalid, not a structural problem with the service config itself.","triggerScenarios":"Calling Dial with a service config whose loadBalancingConfig names a registered policy whose config object fails that policy's parser. Examples: weighted_round_robin with a child entry missing the weight field, xds config with an unknown field under strict parsing, or any policy whose JSON doesn't match its expected schema.","commonSituations":"Upgrading gRPC and a balancer's config schema changed (renamed/required fields); using an xDS-generated config against a client version that expects a different shape; typos in field names within a policy's config block.","solutions":["Read the policy name (%q) and the inner %v error to find the exact field the parser rejected.","Consult that balancer's documentation/schema for the expected config fields and correct them.","Confirm the balancer is registered (import its package, e.g. _ \"google.golang.org/grpc/balancer/weightedroundrobin\") so the parser you expect is the one that ran.","Pin or align client and config-producer versions so the schema matches."],"exampleFix":"// before\n// {\"loadBalancingConfig\": [{\"weighted_round_robin\": {\"children\": [{\"weight\": 10}]}}]}\n//   // missing required \"target\" field on child -> ParseConfig fails\n\n// after\n// {\"loadBalancingConfig\": [{\"weighted_round_robin\": {\"children\": [\n//   {\"target\": \"cluster_a\", \"weight\": 10}\n// ]}}]}","handlingStrategy":"validation","validationCode":"// Preflight: ensure every named policy's config parses.\nfunc preflightLBConfig(raw []byte) error {\n    var bc svcconfig.BalancerConfig\n    if err := json.Unmarshal(raw, &bc); err != nil {\n        return err\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"var bc svcconfig.BalancerConfig\nif err := json.Unmarshal(raw, &bc); err != nil {\n    if strings.Contains(err.Error(), \"error parsing loadBalancingConfig\") {\n        // inner balancer rejected its config; check the policy name + inner error\n    }\n    return err\n}","preventionTips":["Blank-import the balancer packages you reference so the right ConfigParser runs.","Keep config-producer and client versions aligned to avoid schema drift.","Read the specific balancer's config schema (e.g. weightedroundrobin, xds) before authoring."],"tags":["config","loadbalancing","service-config","xds"],"backgroundTag":null,"analyzedSha":"0c51461d27177d997e14c642fe18c11668fc09a3","analyzedAt":"2026-08-11T14:49:15.055Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}