{"record":{"id":"6106fa22375a584f","repo":"grpc/grpc-go","slug":"failed-to-build-child-policy-config-v","errorCode":null,"errorMessage":"failed to build child policy config: %v","messagePattern":"failed to build child policy config: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/xds/balancer/cdsbalancer/cdsbalancer.go","lineNumber":280,"sourceCode":"}\n\n// updateChildConfig builds child policy configuration using endpoint addresses\n// returned from the XDSConfig and child policy configuration.\n//\n// A child policy is created if one doesn't already exist. The newly built\n// configuration is then pushed to the child policy.\nfunc (b *cdsBalancer) updateChildConfig() error {\n\tif b.childLB == nil {\n\t\tchildLB, err := newChildBalancer(b.cc, b.bOpts)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create child policy of type %s: %v\", priority.Name, err)\n\t\t}\n\t\tb.childLB = childLB\n\t}\n\n\tchildCfgBytes, endpoints, err := buildPriorityConfigJSON(b.priorities, &b.xdsLBPolicy)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to build child policy config: %v\", err)\n\t}\n\tchildCfg, err := b.childConfigParser.ParseConfig(childCfgBytes)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to parse child policy config. This should never happen because the config was generated: %v\", err)\n\t}\n\tif b.logger.V(2) {\n\t\tb.logger.Infof(\"Built child policy config: %s\", pretty.ToJSON(childCfg))\n\t}\n\n\tfor i := range endpoints {\n\t\tfor j := range endpoints[i].Addresses {\n\t\t\taddr := endpoints[i].Addresses[j]\n\t\t\taddr.BalancerAttributes = endpoints[i].Attributes\n\t\t\t// BalancerAttributes are used for the following:\n\t\t\t// * Authority Override.\n\t\t\t// * grpc.lb.backend_service metric label propagation.\n\t\t\t// See https://github.com/grpc/grpc-go/issues/6472\n\t\t\tendpoints[i].Addresses[j] = addr","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/grpc/grpc-go/blob/0c51461d27177d997e14c642fe18c11668fc09a3/internal/xds/balancer/cdsbalancer/cdsbalancer.go#L262-L298","documentation":"Returned by updateChildConfig (line 280) when buildPriorityConfigJSON (configbuilder.go:96) fails. buildPriorityConfigJSON delegates to buildPriorityConfig (line 108) which iterates over priorities and calls buildClusterImplConfigForEDS or buildClusterImplConfigForDNS. The inner error is propagated from errors 357 (failed to build priority config) or 358 (failed to marshal).","triggerScenarios":"During a cluster config update, the CDS balancer builds the priority/cluster_impl/outlier-detection/xdsLBPolicy child config tree (see the ASCII diagram in configbuilder.go lines 84-95). If any locality-to-cluster_impl conversion fails (e.g., in priorityLocalitiesToClusterImpl) or the final JSON marshal fails, this error surfaces.","commonSituations":"An internal invariant violation in the config builder (priorityLocalitiesToClusterImpl returns an error). This is rare since the input comes from already-validated xDS resources. Could be triggered by an edge case in endpoint weight computation or locality grouping that the xDS client did not anticipate.","solutions":["Inspect the wrapped %v error to determine whether it came from buildPriorityConfig (error 357) or json.Marshal (error 358).","Check the cluster resource's locality and endpoint data for unusual values (extremely large weights, unexpected endpoint types).","Report the issue to grpc-go with the cluster resource details if the data appears valid but the builder still fails.","Ensure you are on the latest grpc-go patch release in case this is a fixed bug."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// This is an internal error from the config builder. It surfaces as\n// TRANSIENT_FAILURE. Unwrap for diagnostics:\nerr := <-errChan // from your monitoring\nvar inner error\nif errors.As(err, &inner) {\n    log.Printf(\"config builder failed: %v\", inner)\n    // check cluster resource data for anomalies\n}","preventionTips":["Keep grpc-go updated to the latest patch release.","Monitor xDS resource validity on the management server side.","Log cluster resource details when TRANSIENT_FAILURE occurs for post-mortem analysis."],"tags":["xds","config-builder","priority","cluster-impl","cds"],"backgroundTag":null,"analyzedSha":"0c51461d27177d997e14c642fe18c11668fc09a3","analyzedAt":"2026-08-11T14:49:15.055Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}