{"record":{"id":"8b3db3de42a7c8ed","repo":"grpc/grpc-go","slug":"rls-childpolicyconfigtargetfieldname-field-is-not","errorCode":null,"errorMessage":"rls: childPolicyConfigTargetFieldName field is not set in service config %+v","messagePattern":"rls: childPolicyConfigTargetFieldName field is not set in service config %\\+v","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"balancer/rls/config.go","lineNumber":174,"sourceCode":"\trlsProto := &rlspb.RouteLookupConfig{}\n\tif err := m.Unmarshal(cfgJSON.RouteLookupConfig, rlsProto); err != nil {\n\t\treturn nil, fmt.Errorf(\"rls: bad RouteLookupConfig proto %+v: %v\", string(cfgJSON.RouteLookupConfig), err)\n\t}\n\tlbCfg, err := parseRLSProto(rlsProto)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif sc := string(cfgJSON.RouteLookupChannelServiceConfig); sc != \"\" {\n\t\tparsed := internal.ParseServiceConfig.(func(string) *serviceconfig.ParseResult)(sc)\n\t\tif parsed.Err != nil {\n\t\t\treturn nil, fmt.Errorf(\"rls: bad control channel service config %q: %v\", sc, parsed.Err)\n\t\t}\n\t\tlbCfg.controlChannelServiceConfig = sc\n\t}\n\n\tif cfgJSON.ChildPolicyConfigTargetFieldName == \"\" {\n\t\treturn nil, fmt.Errorf(\"rls: childPolicyConfigTargetFieldName field is not set in service config %+v\", string(c))\n\t}\n\tname, config, err := parseChildPolicyConfigs(cfgJSON.ChildPolicy, cfgJSON.ChildPolicyConfigTargetFieldName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlbCfg.childPolicyName = name\n\tlbCfg.childPolicyConfig = config\n\tlbCfg.childPolicyTargetField = cfgJSON.ChildPolicyConfigTargetFieldName\n\treturn lbCfg, nil\n}\n\nfunc parseRLSProto(rlsProto *rlspb.RouteLookupConfig) (*lbConfig, error) {\n\t// Validations specified on the `grpc_keybuilders` field are performed here.\n\tkbMap, err := keys.MakeBuilderMap(rlsProto)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/grpc/grpc-go/blob/0c51461d27177d997e14c642fe18c11668fc09a3/balancer/rls/config.go#L156-L192","documentation":"Emitted from (rlsBB).ParseConfig (config.go:174) when ChildPolicyConfigTargetFieldName is the empty string. The RLS balancer injects each RLS-resolved target into the child policy config under this field name (e.g. round_robin uses 'serviceName'), so it is mandatory.","triggerScenarios":"The top-level JSON config has no childPolicyConfigTargetFieldName key, or its value is an empty string. The check runs after the RouteLookupConfig proto is parsed but before child-policy validation.","commonSituations":"A config template that omits the field; an xDS RLS plugin that was not populated with the target field name; copying an example config that used a different schema version where the field was implicit.","solutions":["Add childPolicyConfigTargetFieldName to the RLS config object with the field name the chosen child policy expects for its target.","For round_robin children use 'round_robin' -> target field 'serviceName'; for pick_first use 'serviceName' as well; confirm against the child policy's config struct.","If the config is xDS-sourced, fix the RouteLookupClusterSpecification on the control plane to include childPolicyConfigTargetFieldName."],"exampleFix":"// before\n{ \"rls\": { \"routeLookupConfig\": { ... }, \"childPolicy\": [ { \"round_robin\": {} } ] } }\n\n// after\n{ \"rls\": {\n    \"routeLookupConfig\": { ... },\n    \"childPolicyConfigTargetFieldName\": \"serviceName\",\n    \"childPolicy\": [ { \"round_robin\": {} } ]\n} }","handlingStrategy":"validation","validationCode":"func validateChildTargetField(name string) error {\n    if strings.TrimSpace(name) == \"\" {\n        return errors.New(\"childPolicyConfigTargetFieldName must be set and non-empty\")\n    }\n    return nil\n}","typeGuard":"func hasChildTargetField(name string) bool { return strings.TrimSpace(name) != \"\" }","tryCatchPattern":null,"preventionTips":["Always pair childPolicy with childPolicyConfigTargetFieldName in config templates.","Document the target field name expected by each candidate child policy (e.g. round_robin -> 'serviceName').","Add a schema/JSON-Schema check for required fields in your config pipeline."],"tags":["rls","child-policy","validation","service-config"],"backgroundTag":null,"analyzedSha":"0c51461d27177d997e14c642fe18c11668fc09a3","analyzedAt":"2026-08-11T14:49:15.055Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}