grpc-ecosystem/grpc-gateway · error

no method %s found

Error message

no method %s found

What it means

Method-level options are matched against fully-qualified method names collected from registered files. If opts.Method names a method whose qualified name ('.' + name) is not among the registered RPC methods, the registry rejects the option entry.

Source

Thrown at internal/descriptor/registry.go:781

		r.fileOptions[opt.File] = opt.Option
	}

	// build map of all registered methods
	methods := make(map[string]struct{})
	services := make(map[string]struct{})
	for _, f := range r.files {
		for _, s := range f.Services {
			services[s.FQSN()] = struct{}{}
			for _, m := range s.Methods {
				methods[m.FQMN()] = struct{}{}
			}
		}
	}

	for _, opt := range opts.Method {
		qualifiedMethod := "." + opt.Method
		if _, ok := methods[qualifiedMethod]; !ok {
			return fmt.Errorf("no method %s found", opt.Method)
		}
		r.methodOptions[qualifiedMethod] = opt.Option
	}

	for _, opt := range opts.Message {
		qualifiedMessage := "." + opt.Message
		if _, ok := r.msgs[qualifiedMessage]; !ok {
			return fmt.Errorf("no message %s found", opt.Message)
		}
		r.messageOptions[qualifiedMessage] = opt.Option
	}

	for _, opt := range opts.Service {
		qualifiedService := "." + opt.Service
		if _, ok := services[qualifiedService]; !ok {
			return fmt.Errorf("no service %s found", opt.Service)
		}
		r.serviceOptions[qualifiedService] = opt.Option

View on GitHub (pinned to a58a4436a3)

Solutions

  1. Use the fully-qualified method name including package and service: pkg.Service.Method
  2. Verify the RPC still exists in the loaded proto files
  3. Ensure the file containing the service was loaded before registering options
  4. Fix casing/typos in the method name in your options file

Example fix

// before
Method: "MyService.MyMethod"
// after
Method: "mypackage.v1.MyService.MyMethod"
Defensive patterns

Strategy: validation

Validate before calling

want := "." + opt.Method
exists := false
for _, f := range loadedFiles { if fileHasMethod(f, want) { exists = true } }
if !exists { return fmt.Errorf("method %q not found; use pkg.Service.Method", opt.Method) }
err = reg.RegisterOptions(opts)

Prevention

When it happens

Trigger: Registering options with opts.Method set to an RPC that does not exist, is misspelled, omits/misspecifies the package/service prefix, or belongs to a file not loaded into this registry.

Common situations: Renaming or deleting an RPC without updating the options config; missing leading package qualifier (e.g. 'mypkg.MyService.MyMethod'); copying options between projects with different package names.

Related errors


AI-assisted analysis of grpc-ecosystem/grpc-gateway@a58a4436a3 (2026-09-02). Data as JSON: /api/errors/209296d3f1a10800. Report an issue: GitHub.