{"record":{"id":"5df35bbf01c198f7","repo":"grpc-ecosystem/grpc-gateway","slug":"no-such-file-given-s","errorCode":null,"errorMessage":"no such file given: %s","messagePattern":"no such file given: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/descriptor/registry.go","lineNumber":410,"sourceCode":"\tif !strings.HasPrefix(location, \".\") {\n\t\tlocation = fmt.Sprintf(\".%s\", location)\n\t}\n\tcomponents := strings.Split(location, \".\")\n\tfor len(components) > 0 {\n\t\tfqen := strings.Join(append(components, name), \".\")\n\t\tif e, ok := r.enums[fqen]; ok {\n\t\t\treturn e, nil\n\t\t}\n\t\tcomponents = components[:len(components)-1]\n\t}\n\treturn nil, fmt.Errorf(\"no enum found: %s\", name)\n}\n\n// LookupFile looks up a file by name.\nfunc (r *Registry) LookupFile(name string) (*File, error) {\n\tf, ok := r.files[name]\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"no such file given: %s\", name)\n\t}\n\treturn f, nil\n}\n\nfunc (r *Registry) GetUseProto3FieldSemantics() bool {\n\treturn r.useProto3FieldSemantics\n}\n\nfunc (r *Registry) SetUseProto3FieldSemantics(useProto3FieldSemantics bool) {\n\tr.useProto3FieldSemantics = useProto3FieldSemantics\n}\n\n// LookupExternalHTTPRules looks up external http rules by fully qualified service method name\nfunc (r *Registry) LookupExternalHTTPRules(qualifiedMethodName string) []*annotations.HttpRule {\n\treturn r.externalHTTPRules[qualifiedMethodName]\n}\n\n// AddExternalHTTPRule adds an external http rule for the given fully qualified service method name","sourceCodeStart":392,"sourceCodeEnd":428,"githubUrl":"https://github.com/grpc-ecosystem/grpc-gateway/blob/a58a4436a376a4bcc7d8f10c4d4f919a8438bba9/internal/descriptor/registry.go#L392-L428","documentation":"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).","triggerScenarios":"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').","commonSituations":"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.","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"],"exampleFix":"// before\nf, err := reg.LookupFile(\"example.proto\")\n// after\nerr := reg.LoadFile(\"example/v1/example.proto\", reg.NewFile(...))\nf, err := reg.LookupFile(\"example/v1/example.proto\")","handlingStrategy":"try-catch","validationCode":"func hasFile(reg *Registry, name string) bool {\n    _, err := reg.LookupFile(name)\n    return err == nil\n}","typeGuard":null,"tryCatchPattern":"f, err := reg.LookupFile(\"example/v1/example.proto\")\nif err != nil {\n    return fmt.Errorf(\"file %s not loaded into registry: %w\", name, err)\n}","preventionTips":["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"],"tags":["protobuf","registry","file-lookup"],"backgroundTag":"file-not-found","analyzedSha":"a58a4436a376a4bcc7d8f10c4d4f919a8438bba9","analyzedAt":"2026-09-02T10:28:31.537Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}