grpc-ecosystem/grpc-gateway · error
no such file given: %s
Error message
no such file given: %s
What it means
Registry.LookupFile returns this error when no File with the given name was loaded into the registry's file map. The name must match the proto file name as loaded (typically the path as given to the generator).
Source
Thrown at internal/descriptor/registry.go:410
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)
}
// LookupFile looks up a file by name.
func (r *Registry) LookupFile(name string) (*File, error) {
f, ok := r.files[name]
if !ok {
return nil, fmt.Errorf("no such file given: %s", name)
}
return f, nil
}
func (r *Registry) GetUseProto3FieldSemantics() bool {
return r.useProto3FieldSemantics
}
func (r *Registry) SetUseProto3FieldSemantics(useProto3FieldSemantics bool) {
r.useProto3FieldSemantics = useProto3FieldSemantics
}
// LookupExternalHTTPRules looks up external http rules by fully qualified service method name
func (r *Registry) LookupExternalHTTPRules(qualifiedMethodName string) []*annotations.HttpRule {
return r.externalHTTPRules[qualifiedMethodName]
}
// AddExternalHTTPRule adds an external http rule for the given fully qualified service method nameView on GitHub (pinned to a58a4436a3)
Solutions
- Call registry.LoadFile / Load the target proto before LookupFile
- Pass the exact same file path string used when loading
- Check case and leading path components of the file name
- For custom tooling, iterate registry's files to confirm registered names
Example fix
// before
f, err := reg.LookupFile("example.proto")
// after
err := reg.LoadFile("example/v1/example.proto", reg.NewFile(...))
f, err := reg.LookupFile("example/v1/example.proto") Defensive patterns
Strategy: try-catch
Validate before calling
func hasFile(reg *Registry, name string) bool {
_, err := reg.LookupFile(name)
return err == nil
} Try / catch
f, err := reg.LookupFile("example/v1/example.proto")
if err != nil {
return fmt.Errorf("file %s not loaded into registry: %w", name, err)
} Prevention
- Load the file before looking it up
- Reuse the identical path string used at LoadFile time
- Confirm registered names when using normalized paths
- Wrap lookups with existence checks in custom tooling and tests
When it happens
Trigger: LookupFile(name) called before registry.LoadFile registered that file, or with a name that differs from the loaded file's path/key (e.g. 'a.proto' vs 'proto/example/v1/a.proto').
Common situations: Resolving field paths in tests or tooling before files are loaded; using a normalized/different path form than the one registered; typo in file name.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- no message found: %s
- no enum found: %s
- no target service defined in the file
- only primitive and enum types are allowed in repeated path p
- only primitive and well-known types are allowed in path para
AI-assisted analysis of grpc-ecosystem/grpc-gateway@a58a4436a3 (2026-09-02).
Data as JSON: /api/errors/5df35bbf01c198f7.
Report an issue: GitHub.