grpc-ecosystem/grpc-gateway · error

no enum found: %s

Error message

no enum found: %s

What it means

Lookup-failure error from Registry.LookupEnum: no enum is registered under the fully-qualified name it tried to resolve (name given as .FQN when leading-dot, else resolved relative to location). Raised by the generic sentinel in the registry, the faulting input is an enum name reference in a proto/annotation that the registry has not loaded or that is misspelled.

Source

Thrown at internal/descriptor/registry.go:387

		fqmn := strings.Join(append(components, name), ".")
		if m, ok := r.msgs[fqmn]; ok {
			return m, nil
		}
		components = components[:len(components)-1]
	}
	return nil, fmt.Errorf("no message found: %s", name)
}

// LookupEnum looks up an enum type by "name".
// It tries to resolve "name" from "location" if "name" is a relative enum name.
func (r *Registry) LookupEnum(location, name string) (*Enum, error) {
	if grpclog.V(1) {
		grpclog.Infof("Lookup enum %s from %s", name, location)
	}
	if strings.HasPrefix(name, ".") {
		e, ok := r.enums[name]
		if !ok {
			return nil, fmt.Errorf("no enum found: %s", name)
		}
		return e, nil
	}

	if !strings.HasPrefix(location, ".") {
		location = fmt.Sprintf(".%s", location)
	}
	components := strings.Split(location, ".")
	for len(components) > 0 {
		fqen := strings.Join(append(components, name), ".")
		if e, ok := r.enums[fqen]; ok {
			return e, nil
		}
		components = components[:len(components)-1]
	}
	return nil, fmt.Errorf("no enum found: %s", name)
}

View on GitHub (pinned to a58a4436a3)

Solutions

  1. Fix the enum name spelling/casing at the usage site.
  2. Ensure the proto file defining the enum is included in the descriptor set passed to the plugin.
  3. Use a fully-qualified (leading-dot) name if resolution from the location fails.

Example fix

// before
reg.LookupEnum(".example.hello.Greeter", ".example.hello.Status")
// after (enum nested in message)
reg.LookupEnum(".example.hello.Greeter", ".example.hello.HelloReply.Status")
Defensive patterns

Strategy: try-catch

Validate before calling

func hasEnum(reg *Registry, fqen string) bool {
    _, err := reg.LookupEnum(".", fqen)
    return err == nil
}

Try / catch

e, err := reg.LookupEnum(loc, ".example.hello.Status")
if err != nil {
    return fmt.Errorf("enum %s not registered: load its proto file: %w", fqen, err)
}

Prevention

When it happens

Trigger: LookupEnum(location, '.example.hello.MyEnum') when the enum was never loaded (its proto file missing) or the FQMN is misspelled (wrong package/nesting).

Common situations: Annotations or query-parameter config referencing an enum from a proto not passed to the generator; enum moved into a message (nested), changing its fully-qualified name; package renames.

Related errors


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