grpc-ecosystem/grpc-gateway · error
no file found
Error message
no file %s found
What it means
When applying per-file options (RegisterOptions/applyOptions), each entry in opts.File must correspond to a file already loaded into the registry. If r.files has no entry for the given file name, the registry cannot attach the option and fails fast with this error.
Solutions
- Use the exact file name as passed to the registry load call (import-path-relative, e.g. 'path/to/file.proto')
- Load the referenced .proto file before registering options
- Remove stale entries from your options configuration for files no longer compiled
- Print/log the keys of loaded files and diff against opts.File entries
Example fix
// before
opts.File = append(opts.File, &FileOption{File: "/abs/path/api.proto", Option: ...})
// after
opts.File = append(opts.File, &FileOption{File: "api.proto", Option: ...}) Defensive patterns
Strategy: validation
Validate before calling
loaded, err := reg.GetAllFQMNs() // or track loaded file names at load time
for _, opt := range opts.File {
if !loadedFiles[opt.File] {
return fmt.Errorf("file %q not loaded; use import-path-relative name", opt.File)
}
}
err = reg.RegisterOptions(opts) Prevention
- Always use the exact file name the registry saw at load time (import-path-relative), never OS paths
- Generate the options file entries from the same file list used for loading
- Prune options entries when removing protos from the build
When it happens
Trigger: Calling the options-registration API with opts.File containing a file name that was never loaded via loadFile/Registry.Load, or loaded under a different (fully-qualified, proto-import-path-relative) name.
Common situations: Passing an absolute path or OS path instead of the proto-relative name used at load time; typo in file name; options file referencing a proto that was removed from the compile set; running the plugin against a subset of protos while the options file covers all.
Related errors
AI-assisted analysis of grpc-ecosystem/grpc-gateway@a58a4436a3 (2026-09-02).
Data as JSON: /api/errors/76ef4cc3bb3639ef.
Report an issue: GitHub.
Appendix: source
Thrown at internal/descriptor/registry.go:761
// SetProto3OptionalNullable set proto3OptionalNullable
func (r *Registry) SetProto3OptionalNullable(proto3OptionalNullable bool) {
r.proto3OptionalNullable = proto3OptionalNullable
}
// GetProto3OptionalNullable returns proto3OptionalNullable
func (r *Registry) GetProto3OptionalNullable() bool {
return r.proto3OptionalNullable
}
// RegisterOpenAPIOptions registers OpenAPI options
func (r *Registry) RegisterOpenAPIOptions(opts *openapiconfig.OpenAPIOptions) error {
if opts == nil {
return nil
}
for _, opt := range opts.File {
if _, ok := r.files[opt.File]; !ok {
return fmt.Errorf("no file %s found", opt.File)
}
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.MethodView on GitHub (pinned to a58a4436a3)