grpc/grpc-go · warning
invalid method name: suffix /method is missing
Error message
invalid method name: suffix /method is missing
What it means
Returned by grpcutil.ParseMethod when the method name starts with '/' but contains no further '/' to separate the service from the method. After stripping the leading slash, the code calls strings.LastIndex looking for '/'; if none is found (pos < 0), the format '/service/method' is not satisfied. This means the string is just '/something' with no method component.
Source
Thrown at internal/grpcutil/method.go:36
package grpcutil
import (
"errors"
"strings"
)
// ParseMethod splits service and method from the input. It expects format
// "/service/method".
func ParseMethod(methodName string) (service, method string, _ error) {
if !strings.HasPrefix(methodName, "/") {
return "", "", errors.New("invalid method name: should start with /")
}
methodName = methodName[1:]
pos := strings.LastIndex(methodName, "/")
if pos < 0 {
return "", "", errors.New("invalid method name: suffix /method is missing")
}
return methodName[:pos], methodName[pos+1:], nil
}
// baseContentType is the base content-type for gRPC. This is a valid
// content-type on its own, but can also include a content-subtype such as
// "proto" as a suffix after "+" or ";". See
// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests
// for more details.
const baseContentType = "application/grpc"
// ContentSubtype returns the content-subtype for the given content-type. The
// given content-type must be a valid content-type that starts with
// "application/grpc". A content-subtype will follow "application/grpc" after a
// "+" or ";". See
// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests for
// more details.
//View on GitHub (pinned to 0c51461d27)
Solutions
- Ensure method names include both service and method separated by '/', e.g., '/package.Service/Method'.
- Validate the method string has at least two '/' characters before calling ParseMethod.
- Check that proxies, load balancers, or service mesh configurations do not truncate the :path header.
- Log the full method path to find where truncation occurs.
Example fix
// before
svc, method, err := grpcutil.ParseMethod("/myapp.UserService")
// after
svc, method, err := grpcutil.ParseMethod("/myapp.UserService/GetUser") Defensive patterns
Strategy: validation
Validate before calling
// Validate method name has both service and method components.
func isValidMethodName(method string) bool {
if !strings.HasPrefix(method, "/") { return false }
rest := method[1:]
return strings.Count(rest, "/") >= 1 && !strings.HasSuffix(rest, "/")
}
if !isValidMethodName(method) {
return fmt.Errorf("method %q must be '/package.Service/Method'", method)
} Try / catch
svc, method, err := grpcutil.ParseMethod(name)
if err != nil {
log.Printf("malformed method name %q: %v", name, err)
return err
} Prevention
- Ensure method names always include '/Service/Method' after the leading slash.
- Validate externally-supplied method strings before parsing.
- Check that proxies do not truncate the :path header.
- Use well-formed method names from gRPC framework rather than manual construction.
When it happens
Trigger: Calling ParseMethod with a string like '/ServiceName' (no trailing '/Method'), or '/ServiceName/' (trailing slash but no method after it). Happens when method paths are truncated, malformed, or constructed incorrectly.
Common situations: Proxies or gateways that truncate the gRPC path; incorrect service config method patterns; test fixtures or mocks with incomplete method names; manual path string construction missing the method suffix.
Related errors
- invalid method name: should start with /
- buffer size is not an exponent of two
- profiling may be initialized at most once
- server-side auth info is not of type alts.AuthInfo
- message authentication failed
AI-assisted analysis of grpc/grpc-go@0c51461d27 (2026-08-11).
Data as JSON: /api/errors/f9a55a2c44d5b98b.
Report an issue: GitHub.