{"record":{"id":"65fe4f891902517d","repo":"micro/go-micro","slug":"unknown-request-path","errorCode":null,"errorMessage":"unknown request path","messagePattern":"unknown request path","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"codec/grpc/grpc.go","lineNumber":39,"sourceCode":"func (c *Codec) ReadHeader(m *codec.Message, t codec.MessageType) error {\n\tif ct := m.Header[\"Content-Type\"]; len(ct) > 0 {\n\t\tc.ContentType = ct\n\t}\n\n\tif ct := m.Header[\"content-type\"]; len(ct) > 0 {\n\t\tc.ContentType = ct\n\t}\n\n\t// service method\n\tpath := m.Header[\":path\"]\n\tif len(path) == 0 || path[0] != '/' {\n\t\tm.Target = m.Header[headers.Request]\n\t\tm.Endpoint = m.Header[headers.Endpoint]\n\t} else {\n\t\t// [ , a.package.Foo, Bar]\n\t\tparts := strings.Split(path, \"/\")\n\t\tif len(parts) != 3 {\n\t\t\treturn errors.New(\"unknown request path\")\n\t\t}\n\t\tservice := strings.Split(parts[1], \".\")\n\t\tm.Endpoint = strings.Join([]string{service[len(service)-1], parts[2]}, \".\")\n\t\tm.Target = strings.Join(service[:len(service)-1], \".\")\n\t}\n\n\treturn nil\n}\n\nfunc (c *Codec) ReadBody(b interface{}) error {\n\t// no body\n\tif b == nil {\n\t\treturn nil\n\t}\n\n\t_, buf, err := decode(c.Conn)\n\tif err != nil {\n\t\treturn err","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/codec/grpc/grpc.go#L21-L57","documentation":"The go-micro gRPC codec parses the HTTP/2 \":path\" header of an incoming request to derive the target service and endpoint. It expects exactly the gRPC form \"/package.Service/Method\", i.e. splitting on \"/\" must yield exactly 3 parts. If the path header is missing its leading slash, has extra segments, or is otherwise malformed, ReadHeader returns \"unknown request path\" and the request is rejected before any handler runs.","triggerScenarios":"ReadHeader is called with m.Header[\":path\"] set to a value starting with '/' (so the gRPC parsing branch is taken) but whose strings.Split(path, \"/\") does not produce exactly 3 parts — e.g. \"/service.Method\" (missing method segment), \"/a/b/c/d\" (extra segments), or a trailing slash like \"/pkg.Svc/Method/\".","commonSituations":"Pointing a non-go-micro gRPC client at a go-micro server with an unusual full method name; a proxy or gateway rewriting/trimming the :path; manually hand-crafting gRPC frames in tests with an incorrect path; version drift where an older client encodes the target in a different path layout.","solutions":["Fix the caller to send a standard gRPC path of the form \"/package.Service/Method\" (leading slash, exactly one service segment, one method segment).","If the request is not real gRPC, omit or fix the \":path\" header so ReadHeader falls back to the headers.Request/headers.Endpoint branch.","Log the raw \":path\" value at the gateway/proxy layer and correct the rewrite rule that is mangling it.","Ensure client and server go-micro versions agree on how the method path is encoded (upgrade both to the same version)."],"exampleFix":"// before (hand-crafted request)\nheader.Set(\":path\", \"/helloworld.Greeter\")\n// after\nheader.Set(\":path\", \"/helloworld.Greeter/SayHello\")","handlingStrategy":"validation","validationCode":"path := header.Get(\":path\")\nif strings.HasPrefix(path, \"/\") && len(strings.Split(path, \"/\")) != 3 {\n    return fmt.Errorf(\"malformed gRPC path %q: want /package.Service/Method\", path)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always send standard gRPC \"/package.Service/Method\" paths from clients and gateways.","Log the raw :path at proxy boundaries to catch rewrite bugs early.","Add a test that round-trips every RPC method path through the codec.","Pin client and server go-micro versions to the same release."],"tags":["grpc","codec","request-parsing","go"],"backgroundTag":"grpc-invalid-request-path","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}