{"record":{"id":"5d91b202ee6a3520","repo":"grpc/grpc-go","slug":"failed-to-build-priority-config-v","errorCode":null,"errorMessage":"failed to build priority config: %v","messagePattern":"failed to build priority config: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/xds/balancer/cdsbalancer/configbuilder.go","lineNumber":99,"sourceCode":"// priorities.\n//\n// The built tree of balancers (see test for the output struct).\n//\n//\t          ┌────────┐\n//\t          │priority│\n//\t          └┬──────┬┘\n//\t           │      │\n//\t┌──────────▼─┐  ┌─▼──────────┐\n//\t│cluster_impl│  │cluster_impl│\n//\t└──────┬─────┘  └─────┬──────┘\n//\t       │              │\n//\t┌──────▼─────┐  ┌─────▼──────┐\n//\t│xDSLBPolicy │  │xDSLBPolicy │ (Locality and Endpoint picking layer)\n//\t└────────────┘  └────────────┘\nfunc buildPriorityConfigJSON(priorities []*priorityConfig, xdsLBPolicy *internalserviceconfig.BalancerConfig) ([]byte, []resolver.Endpoint, error) {\n\tpc, endpoints, err := buildPriorityConfig(priorities, xdsLBPolicy)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to build priority config: %v\", err)\n\t}\n\tret, err := json.Marshal(pc)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to marshal built priority config struct into json: %v\", err)\n\t}\n\treturn ret, endpoints, nil\n}\n\nfunc buildPriorityConfig(priorities []*priorityConfig, xdsLBPolicy *internalserviceconfig.BalancerConfig) (*priority.LBConfig, []resolver.Endpoint, error) {\n\tvar (\n\t\tretConfig    = &priority.LBConfig{Children: make(map[string]*priority.Child)}\n\t\tretEndpoints []resolver.Endpoint\n\t)\n\tfor _, p := range priorities {\n\t\tclusterUpdate := p.clusterConfig.Cluster\n\t\tswitch clusterUpdate.ClusterType {\n\t\tcase xdsresource.ClusterTypeEDS:\n\t\t\tnames, configs, endpoints, err := buildClusterImplConfigForEDS(p.childNameGen, p.clusterConfig, xdsLBPolicy)","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/grpc/grpc-go/blob/0c51461d27177d997e14c642fe18c11668fc09a3/internal/xds/balancer/cdsbalancer/configbuilder.go#L81-L117","documentation":"Returned by buildPriorityConfigJSON (configbuilder.go:99) when buildPriorityConfig (line 108) returns an error. buildPriorityConfig iterates over priorities and for each EDS cluster calls buildClusterImplConfigForEDS (line 117), and for each DNS cluster calls buildClusterImplConfigForDNS (line 133). The EDS path can return an error from priorityLocalitiesToClusterImpl (line 222) if locality/endpoint processing fails.","triggerScenarios":"During child config construction for a CDS cluster, buildClusterImplConfigForEDS calls priorityLocalitiesToClusterImpl which processes localities and endpoints. If this function returns an error (currently it always returns nil error in the read code, but the signature allows it), the error propagates through buildPriorityConfig to buildPriorityConfigJSON and then to updateChildConfig as error 349.","commonSituations":"An unexpected error in locality-to-cluster_impl conversion. Since the current priorityLocalitiesToClusterImpl does not return errors for any known condition, this error path is a safety net. If it does fire, it likely indicates a code path added in a future version or a modification.","solutions":["Inspect the wrapped %v to find the specific failure in the priority config builder.","Examine the cluster's locality and endpoint data for edge cases (zero localities, unusual weights).","Check if a newer grpc-go version added validation that your data triggers.","Report with cluster resource details to grpc-go maintainers if the data appears valid."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Internal config builder error; surfaces as TRANSIENT_FAILURE.\n// Unwrap for diagnostics:\nerr := getChannelError(conn)\nif err != nil && strings.Contains(err.Error(), \"failed to build priority config\") {\n    inner := errors.Unwrap(err)\n    log.Printf(\"priority config build inner error: %v\", inner)\n    // inspect cluster locality/endpoint data\n}","preventionTips":["Keep grpc-go updated to benefit from bug fixes in the config builder.","Validate cluster resources on the management server before deployment.","Log full cluster resource details when debugging xDS issues."],"tags":["xds","config-builder","priority","cluster-impl","eds"],"backgroundTag":null,"analyzedSha":"0c51461d27177d997e14c642fe18c11668fc09a3","analyzedAt":"2026-08-11T14:49:15.055Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}