grpc-ecosystem/grpc-gateway · error · errNoTargetService

no target service defined in the file

Error message

no target service defined in the file

What it means

Sentinel error errNoTargetService raised when a proto FileDescriptor contains no service with google.api.Http annotations (or none selected via the registry). The gateway generator returns it to signal that nothing should be generated for this file; the plugin treats it as a benign skip (logged only at grpclog V(1)) rather than a hard failure.

Source

Thrown at protoc-gen-grpc-gateway/internal/gengateway/generator.go:16

package gengateway

import (
	"errors"
	"fmt"
	"go/format"
	"path"

	"github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor"
	gen "github.com/grpc-ecosystem/grpc-gateway/v2/internal/generator"
	"google.golang.org/grpc/grpclog"
	"google.golang.org/protobuf/proto"
	"google.golang.org/protobuf/types/pluginpb"
)

var errNoTargetService = errors.New("no target service defined in the file")

type generator struct {
	reg                *descriptor.Registry
	baseImports        []descriptor.GoPackage
	useRequestContext  bool
	registerFuncSuffix string
	allowPatchFeature  bool
	standalone         bool
	useOpaqueAPI       bool
}

// New returns a new generator which generates grpc gateway files.
func New(reg *descriptor.Registry, useRequestContext bool, registerFuncSuffix string,
	allowPatchFeature, standalone bool, useOpaqueAPI bool) gen.Generator {
	var imports []descriptor.GoPackage
	for _, pkgpath := range []string{
		"context",
		"errors",

View on GitHub (pinned to a58a4436a3)

Solutions

  1. If generation is expected, add a service with google.api.http annotations (or google.api.http rules) to the proto file.
  2. Verify the service name is not filtered out by the plugin's service allow/deny configuration.
  3. Ignore if the file legitimately contains no HTTP-annotated services.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at protoc-gen-grpc-gateway/internal/gengateway/generator.go:16 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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