grafana/k6 · error

can't get method on service %q: %w

Error message

can't get method on service %q: %w

What it means

While walking the services returned by reflection, the client could not resolve the file descriptor for a method on the named service. The server listed the service but then failed to serve its descriptors (partial registration, missing dependencies, or a server-side reflection bug). The error names the offending service, and the descriptor set build aborts.

Source

Thrown at internal/lib/netext/grpcext/reflect.go:37

// It is called in the connect function the first time the Client.Connect function is called.
func (rc *reflectionClient) Reflect(ctx context.Context) (*descriptorpb.FileDescriptorSet, error) {
	client := grpcreflect.NewClientAuto(ctx, rc.Conn)
	client.AllowMissingFileDescriptors()

	services, err := client.ListServices()
	if err != nil {
		return nil, fmt.Errorf("can't list services: %w", err)
	}

	seen := make(map[fileDescriptorLookupKey]bool, len(services))
	fdset := &descriptorpb.FileDescriptorSet{
		File: make([]*descriptorpb.FileDescriptorProto, 0, len(services)),
	}

	for _, srv := range services {
		srvDescriptor, err := client.ResolveService(srv)
		if err != nil {
			return nil, fmt.Errorf("can't get method on service %q: %w", srv, err)
		}

		stack := []*desc.FileDescriptor{srvDescriptor.GetFile()}

		for len(stack) > 0 {
			fdp := stack[len(stack)-1]
			stack = stack[:len(stack)-1]

			fdkey := fileDescriptorLookupKey{
				Package: fdp.GetPackage(),
				Name:    fdp.GetName(),
			}

			stack = append(stack, fdp.GetDependencies()...)

			if seen[fdkey] {
				// When a proto file contains declarations for multiple services
				// then the same proto file is returned multiple times,

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Verify the service's protobuf file and all its transitive imports are compiled into the server binary
  2. Re-register the service and its reflection metadata on the server; restart it
  3. If the server's reflection is unreliable, use a local proto bundle for the client instead
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/lib/netext/grpcext/reflect.go:37 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/d2b1b3a367c8fe2a. Report an issue: GitHub.