{"record":{"id":"6c4d3c6964f8aab8","repo":"grpc/grpc-go","slug":"lb-policy-name-q-found-in-children-field-v-is","errorCode":null,"errorMessage":"LB policy name %q found in Children field (%v) is not found in Priorities field (%+v)","messagePattern":"LB policy name %q found in Children field \\((.+?)\\) is not found in Priorities field \\(%\\+v\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/xds/balancer/priority/config.go","lineNumber":63,"sourceCode":"\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":45,"sourceCodeEnd":68,"githubUrl":"https://github.com/grpc/grpc-go/blob/0c51461d27177d997e14c642fe18c11668fc09a3/internal/xds/balancer/priority/config.go#L45-L68","documentation":"priority's parseConfig also verifies every child in Children is referenced by Priorities (config.go:61-64). An orphan child defined in Children but not listed in Priorities is rejected during ParseConfig, since priority would never be able to use it.","triggerScenarios":"cfg.Children has a key that is not present in cfg.Priorities (e.g. children: {\"child-A\": ..., \"child-B\": ...} but priorities only lists \"child-A\").","commonSituations":"Manual priority config construction with mismatched fields; xDS resource defining a child that the priority order omits; refactoring that removes a name from Priorities but leaves it in Children.","solutions":["Ensure every key in Children appears exactly once in Priorities.","Generate the config from a single source of truth so the two fields cannot drift.","Inspect the full error message: it prints both Children and Priorities for quick comparison."],"exampleFix":"// before\n{\n  \"children\": {\"child-A\": {...}, \"child-B\": {...}},\n  \"priorities\": [\"child-A\"]\n}\n// after\n{\n  \"children\": {\"child-A\": {...}, \"child-B\": {...}},\n  \"priorities\": [\"child-A\", \"child-B\"]\n}","handlingStrategy":"validation","validationCode":"func validateChildrenReferencedInPriorities(cfg *priority.LBConfig) error {\n    inPriorities := make(map[string]bool, len(cfg.Priorities))\n    for _, p := range cfg.Priorities { inPriorities[p] = true }\n    for name := range cfg.Children {\n        if !inPriorities[name] {\n            return fmt.Errorf(\"child %q is not in Priorities\", name)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Generate Priorities as the ordered list of every Children map key.","Add a unit test that asserts every Children entry is referenced by Priorities.","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"}