{"record":{"id":"253fa02406ef5817","repo":"grpc/grpc-go","slug":"unexpected-balancer-config-with-type-t-253fa0","errorCode":null,"errorMessage":"unexpected balancer config with type: %T","messagePattern":"unexpected balancer config with type: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/xds/balancer/priority/balancer.go","lineNumber":123,"sourceCode":"\tpriorities []string\n\t// children is a map from child name to sub-balancers.\n\tchildren map[string]*childBalancer\n\n\t// Set during UpdateClientConnState when calling into sub-balancers.\n\t// Prevents child updates from recomputing the active priority or sending\n\t// an update of the aggregated picker to the parent.  Cleared after all\n\t// sub-balancers have finished UpdateClientConnState, after which\n\t// syncPriority is called manually.\n\tinhibitPickerUpdates bool\n}\n\nfunc (b *priorityBalancer) UpdateClientConnState(s balancer.ClientConnState) error {\n\tif b.logger.V(2) {\n\t\tb.logger.Infof(\"Received an update with balancer config: %+v\", pretty.ToJSON(s.BalancerConfig))\n\t}\n\tnewConfig, ok := s.BalancerConfig.(*LBConfig)\n\tif !ok {\n\t\treturn fmt.Errorf(\"unexpected balancer config with type: %T\", s.BalancerConfig)\n\t}\n\tendpointsSplit := hierarchy.Group(s.ResolverState.Endpoints)\n\n\tb.mu.Lock()\n\t// Create and remove children, since we know all children from the config\n\t// are used by some priority.\n\tfor name, newSubConfig := range newConfig.Children {\n\t\tbb := balancer.Get(newSubConfig.Config.Name)\n\t\tif bb == nil {\n\t\t\tb.logger.Errorf(\"balancer name %v from config is not registered\", newSubConfig.Config.Name)\n\t\t\tcontinue\n\t\t}\n\n\t\tcurrentChild, ok := b.children[name]\n\t\tif !ok {\n\t\t\t// This is a new child, add it to the children list. But note that\n\t\t\t// the balancer isn't built, because this child can be a low\n\t\t\t// priority. If necessary, it will be built when syncing priorities.","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/grpc/grpc-go/blob/0c51461d27177d997e14c642fe18c11668fc09a3/internal/xds/balancer/priority/balancer.go#L105-L141","documentation":"priority's UpdateClientConnState asserts s.BalancerConfig is *priority.LBConfig (balancer.go:121-123). Any other type is rejected because priority needs the Children map and ordered Priorities list to manage its sub-balancers.","triggerScenarios":"UpdateClientConnState called on the priority balancer with a BalancerConfig that is not *priority.LBConfig; usually means the xDS resolver produced the wrong config or a custom parent bypassed ParseConfig.","commonSituations":"Custom resolver that does not use priority.ParseConfig; gRPC version drift; tests that pass a raw struct.","solutions":["Always route config through priority.ParseConfig(rawJSON) to produce *LBConfig.","Ensure the resolver's service config produces the priority_experimental policy with the expected Children/Priorities JSON shape.","Verify the parent policy forwards the exact *LBConfig returned by ParseConfig."],"exampleFix":"// before\nb.UpdateClientConnState(balancer.ClientConnState{\n    BalancerConfig: &someOtherConfig{},\n})\n// after\nimport \"google.golang.org/grpc/internal/xds/balancer/priority\"\ncfg, err := priority.ParseConfig(rawJSON)\nif err != nil { return err }\nb.UpdateClientConnState(balancer.ClientConnState{BalancerConfig: cfg})","handlingStrategy":"type-guard","validationCode":"func validatePriorityConfig(cfg serviceconfig.LoadBalancingConfig) error {\n    if _, ok := cfg.(*priority.LBConfig); !ok {\n        return fmt.Errorf(\"expected *priority.LBConfig, got %T\", cfg)\n    }\n    return nil\n}","typeGuard":"func isPriorityConfig(cfg serviceconfig.LoadBalancingConfig) bool {\n    _, ok := cfg.(*priority.LBConfig)\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Always produce the config via priority.ParseConfig rather than constructing it manually.","Do not translate the config into a different type between resolver and balancer.","Pin resolver and balancer packages to the same gRPC-go version."],"tags":["go","grpc","xds","balancer","config-type","priority"],"backgroundTag":null,"analyzedSha":"0c51461d27177d997e14c642fe18c11668fc09a3","analyzedAt":"2026-08-11T14:49:15.055Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}