{"record":{"id":"e05f8b03b9363db3","repo":"grpc/grpc-go","slug":"lb-policy-name-q-found-in-priorities-field-v-i","errorCode":null,"errorMessage":"LB policy name %q found in Priorities field (%v) is not found in Children field (%+v)","messagePattern":"LB policy name %q found in Priorities field \\((.+?)\\) is not found in Children field \\(%\\+v\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/xds/balancer/priority/config.go","lineNumber":57,"sourceCode":"\t// Children is a map from the child balancer names to their configs. Child\n\t// names can be found in field Priorities.\n\tChildren map[string]*Child `json:\"children,omitempty\"`\n\t// Priorities is a list of child balancer names. They are sorted from\n\t// highest priority to low. The type/config for each child can be found in\n\t// field Children, with the balancer name as the key.\n\tPriorities []string `json:\"priorities,omitempty\"`\n}\n\nfunc parseConfig(c json.RawMessage) (*LBConfig, error) {\n\tvar cfg LBConfig\n\tif err := json.Unmarshal(c, &cfg); err != nil {\n\t\treturn nil, err\n\t}\n\n\tprioritiesSet := make(map[string]bool)\n\tfor _, name := range cfg.Priorities {\n\t\tif _, ok := cfg.Children[name]; !ok {\n\t\t\treturn nil, fmt.Errorf(\"LB policy name %q found in Priorities field (%v) is not found in Children field (%+v)\", name, cfg.Priorities, cfg.Children)\n\t\t}\n\t\tprioritiesSet[name] = true\n\t}\n\tfor name := range cfg.Children {\n\t\tif _, ok := prioritiesSet[name]; !ok {\n\t\t\treturn nil, fmt.Errorf(\"LB policy name %q found in Children field (%v) is not found in Priorities field (%+v)\", name, cfg.Children, cfg.Priorities)\n\t\t}\n\t}\n\treturn &cfg, nil\n}\n","sourceCodeStart":39,"sourceCodeEnd":68,"githubUrl":"https://github.com/grpc/grpc-go/blob/0c51461d27177d997e14c642fe18c11668fc09a3/internal/xds/balancer/priority/config.go#L39-L68","documentation":"priority's parseConfig cross-checks every name in the Priorities list against the Children map (config.go:55-58). A name present in Priorities but absent from Children is an inconsistent config and is rejected during ParseConfig, before any balancer is built.","triggerScenarios":"cfg.Priorities contains a name that is not a key in cfg.Children (e.g. priorities: [\"child-A\", \"child-B\"] but children only has \"child-A\").","commonSituations":"Manual priority config construction with mismatched fields; xDS resource with priority order referencing an undefined child; refactoring that renames a child in one field but not the other.","solutions":["Ensure every entry in Priorities has a matching key in Children.","Generate the config from a single source of truth so the two fields cannot drift.","Inspect the full error message: it prints both Priorities and Children for quick comparison."],"exampleFix":"// before\n{\n  \"children\": {\"child-A\": {\"config\": {...}}},\n  \"priorities\": [\"child-A\", \"child-B\"]\n}\n// after\n{\n  \"children\": {\"child-A\": {\"config\": {...}}, \"child-B\": {\"config\": {...}}},\n  \"priorities\": [\"child-A\", \"child-B\"]\n}","handlingStrategy":"validation","validationCode":"func validatePrioritiesReferencedInChildren(cfg *priority.LBConfig) error {\n    for _, p := range cfg.Priorities {\n        if _, ok := cfg.Children[p]; !ok {\n            return fmt.Errorf(\"priority %q is not in Children\", p)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Generate Priorities from the Children map keys so the two fields cannot drift.","Add a unit test that asserts every Priorities entry has a Children entry.","Inspect the full error message which prints both fields for quick diffing."],"tags":["go","grpc","xds","balancer","config","priority"],"backgroundTag":null,"analyzedSha":"0c51461d27177d997e14c642fe18c11668fc09a3","analyzedAt":"2026-08-11T14:49:15.055Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}