{"record":{"id":"f5881d9febca5254","repo":"grpc/grpc-go","slug":"rls-grpckeybuilder-in-routelookupconfig-contains-f5881d","errorCode":null,"errorMessage":"rls: GrpcKeyBuilder in RouteLookupConfig contains a method with a slash {%+v}","messagePattern":"rls: GrpcKeyBuilder in RouteLookupConfig contains a method with a slash (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"balancer/rls/internal/keys/builder.go","lineNumber":94,"sourceCode":"\t\t\tconstantKeys: constantKeys,\n\t\t\thostKey:      kb.GetExtraKeys().GetHost(),\n\t\t\tserviceKey:   kb.GetExtraKeys().GetService(),\n\t\t\tmethodKey:    kb.GetExtraKeys().GetMethod(),\n\t\t}\n\n\t\t// Store the builder created above in the BuilderMap based on the value\n\t\t// of the `Names` field, which wraps incoming request's service and\n\t\t// method. Also, ensure that there are no repeated `Names` field.\n\t\tnames := kb.GetNames()\n\t\tif len(names) == 0 {\n\t\t\treturn nil, fmt.Errorf(\"rls: GrpcKeyBuilder in RouteLookupConfig does not contain any Name {%+v}\", kbs)\n\t\t}\n\t\tfor _, name := range names {\n\t\t\tif name.GetService() == \"\" {\n\t\t\t\treturn nil, fmt.Errorf(\"rls: GrpcKeyBuilder in RouteLookupConfig contains a Name field with no Service {%+v}\", kbs)\n\t\t\t}\n\t\t\tif strings.Contains(name.GetMethod(), `/`) {\n\t\t\t\treturn nil, fmt.Errorf(\"rls: GrpcKeyBuilder in RouteLookupConfig contains a method with a slash {%+v}\", kbs)\n\t\t\t}\n\t\t\tpath := \"/\" + name.GetService() + \"/\" + name.GetMethod()\n\t\t\tif _, ok := bm[path]; ok {\n\t\t\t\treturn nil, fmt.Errorf(\"rls: GrpcKeyBuilder in RouteLookupConfig contains repeated Name field {%+v}\", kbs)\n\t\t\t}\n\t\t\tbm[path] = b\n\t\t}\n\t}\n\treturn bm, nil\n}\n\n// KeyMap represents the RLS keys to be used for a request.\ntype KeyMap struct {\n\t// Map is the representation of an RLS key as a Go map. This is used when\n\t// an actual RLS request is to be sent out on the wire, since the\n\t// RouteLookupRequest proto expects a Go map.\n\tMap map[string]string\n\t// Str is the representation of an RLS key as a string, sorted by keys.","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/grpc/grpc-go/blob/03255a9237b6eb32710f6bc4f2de9a675b99fe36/balancer/rls/internal/keys/builder.go#L76-L112","documentation":"The library itself constructs the /service/method path from the Name's service and method fields, so the method field must be the bare method name with no slashes. If strings.Contains(method, \"/\") is true, MakeBuilderMap rejects it because the resulting path would have extra segments and break the path split logic in BuilderMap.RLSKey.","triggerScenarios":"A Name like {service:\"pkg.Svc\", method:\"Sub/Get\"} or method:\"/Get\" — any method containing a '/' character.","commonSituations":"Putting the full /service/method into the method field; splitting a method name into namespace-like segments with slashes; copy-paste from a path string.","solutions":["Put only the bare method name in method (e.g. \"Get\", not \"Sub/Get\").","If you need a sub-path, encode it differently (the gRPC method name itself cannot contain a slash).","Strip leading/trailing slashes from the method field before validation."],"exampleFix":"// before\n{\"names\":[{\"service\":\"pkg.Svc\",\"method\":\"Sub/Get\"}]}\n// after\n{\"names\":[{\"service\":\"pkg.Svc\",\"method\":\"Get\"}]}","handlingStrategy":"validation","validationCode":"func validateNameMethodNoSlash(cfg *rlspb.RouteLookupConfig) error {\n    for bi, kb := range cfg.GetGrpcKeybuilders() {\n        for ni, n := range kb.GetNames() {\n            if strings.Contains(n.GetMethod(), \"/\") {\n                return fmt.Errorf(\"keybuilder[%d].names[%d] method %q contains '/'\", bi, ni, n.GetMethod())\n            }\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Put only the bare method name in the method field.","Never paste a full /service/method string into method.","Strip slashes when converting paths to Name protos."],"tags":["rls","service-config","config-validation","go","grpc","key-builder"],"analyzedSha":"03255a9237b6eb32710f6bc4f2de9a675b99fe36","analyzedAt":"2026-08-07T00:29:34.215Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}