{"record":{"id":"0f8e94d1202a05b4","repo":"grpc/grpc-go","slug":"must-come-in-between-service-and-method-only-on","errorCode":null,"errorMessage":"/ must come in between service and method, only one /","messagePattern":"/ must come in between service and method, only one /","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gcp/observability/config.go","lineNumber":65,"sourceCode":"\t\treturn \"\"\n\t}\n\tif credentials.ProjectID == \"\" {\n\t\tlogger.Infof(\"Failed to find project ID in default credential: %v\", err)\n\t\treturn \"\"\n\t}\n\tlogger.Infof(\"Found project ID from Google Default Credential: %v\", credentials.ProjectID)\n\treturn credentials.ProjectID\n}\n\n// validateMethodString validates whether the string passed in is a valid\n// pattern.\nfunc validateMethodString(method string) error {\n\tif strings.HasPrefix(method, \"/\") {\n\t\treturn errors.New(\"cannot have a leading slash\")\n\t}\n\tserviceMethod := strings.Split(method, \"/\")\n\tif len(serviceMethod) != 2 {\n\t\treturn errors.New(\"/ must come in between service and method, only one /\")\n\t}\n\tif serviceMethod[1] == \"\" {\n\t\treturn errors.New(\"method name must be non empty\")\n\t}\n\tif serviceMethod[0] == \"*\" {\n\t\treturn errors.New(\"cannot have service wildcard * i.e. (*/m)\")\n\t}\n\treturn nil\n}\n\nfunc validateLogEventMethod(methods []string, exclude bool) error {\n\tfor _, method := range methods {\n\t\tif method == \"*\" {\n\t\t\tif exclude {\n\t\t\t\treturn errors.New(\"cannot have exclude and a '*' wildcard\")\n\t\t\t}\n\t\t\tcontinue\n\t\t}","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/grpc/grpc-go/blob/0c51461d27177d997e14c642fe18c11668fc09a3/gcp/observability/config.go#L47-L83","documentation":"Returned by validateMethodString when the method pattern does not contain exactly one '/' separator between the service name and method name. The function splits the string by '/' and requires exactly two parts. Zero slashes (e.g., fooBar) or multiple slashes (e.g., a/b/c) both trigger this error.","triggerScenarios":"A method entry in the observability logging config has no slash (e.g., Foo) or more than one slash (e.g., pkg/Foo/Bar). The pattern must be exactly service/method.","commonSituations":"Developers enter a bare service name without a method, or a fully-qualified path with extra segments. Misunderstanding the expected format as a URL-like path with multiple segments.","solutions":["Ensure each method pattern has exactly one '/' separating the fully-qualified service name from the method name: pkg.Service/Method.","Use the '*' wildcard for the method part (pkg.Service/*) to match all methods in a service."],"exampleFix":"// before\n{\"methods\":[\"foo.Bar.Baz\"]} // no slash → error\n// after\n{\"methods\":[\"foo.Bar/Baz\"]} // service/method","handlingStrategy":"validation","validationCode":"parts := strings.Split(method, \"/\")\nif len(parts) != 2 {\n    return fmt.Errorf(\"method must be service/method with exactly one /, got %d parts\", len(parts))\n}","typeGuard":"func isValidMethodPattern(m string) bool {\n    parts := strings.Split(m, \"/\")\n    return len(parts) == 2 && parts[0] != \"\" && parts[1] != \"\"\n}","tryCatchPattern":null,"preventionTips":["Ensure exactly one '/' separates service and method in each pattern.","Validate the pattern format before writing it to the config.","Use fully-qualified service names (pkg.Service)."],"tags":["go","grpc","observability","config","validation"],"backgroundTag":null,"analyzedSha":"0c51461d27177d997e14c642fe18c11668fc09a3","analyzedAt":"2026-08-11T14:49:15.055Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}