{"record":{"id":"fa663b5844e5bf95","repo":"grpc-ecosystem/grpc-gateway","slug":"unknown-enum-type-s","errorCode":null,"errorMessage":"unknown enum type %s","messagePattern":"unknown enum type (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"protoc-gen-openapiv2/internal/genopenapi/template.go","lineNumber":415,"sourceCode":"\t\t\tItems:       schema.Items,\n\t\t\tFormat:      schema.Format,\n\t\t\tPattern:     schema.Pattern,\n\t\t\tRequired:    required,\n\t\t\tDeprecated:  deprecated,\n\t\t\tUniqueItems: schema.UniqueItems,\n\t\t\textensions:  schema.extensions,\n\t\t\tEnum:        schema.Enum,\n\t\t}\n\t\tif param.Type == \"array\" {\n\t\t\tparam.CollectionFormat = \"multi\"\n\t\t}\n\n\t\tparam.Name = prefix + reg.FieldName(field)\n\n\t\tif isEnum {\n\t\t\tenum, err := reg.LookupEnum(\"\", fieldType)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"unknown enum type %s\", fieldType)\n\t\t\t}\n\t\t\tif items != nil { // array\n\t\t\t\tparam.Items = &openapiItemsObject{\n\t\t\t\t\tschemaCore: schemaCore{\n\t\t\t\t\t\tType: \"string\",\n\t\t\t\t\t\tEnum: listEnumNames(reg, enum),\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t\tif reg.GetEnumsAsInts() {\n\t\t\t\t\tparam.Items.Type = \"integer\"\n\t\t\t\t\tparam.Items.Enum = listEnumNumbers(reg, enum)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tparam.Type = \"string\"\n\t\t\t\tparam.Enum = listEnumNames(reg, enum)\n\t\t\t\tparam.Default = getEnumDefault(reg, enum)\n\t\t\t\tif reg.GetEnumsAsInts() {\n\t\t\t\t\tparam.Type = \"integer\"","sourceCodeStart":397,"sourceCodeEnd":433,"githubUrl":"https://github.com/grpc-ecosystem/grpc-gateway/blob/a58a4436a376a4bcc7d8f10c4d4f919a8438bba9/protoc-gen-openapiv2/internal/genopenapi/template.go#L397-L433","documentation":"In genopenapi's nestedQueryParams, when a query parameter field is an enum, the registry is asked to look up the enum type; failure produces 'unknown enum type %s'. This means the enum referenced by a query-path field cannot be found in the registry — the descriptor wasn't loaded or the type name doesn't match any registered enum.","triggerScenarios":"queryParams/nestedQueryParams recursion hits an enum field whose reg.LookupEnum(\"\", fieldType) fails — enum defined in a dependency not included in the protoc run, or a type-name mismatch (fieldType string not matching any registered enum FQMN).","commonSituations":"Query parameters reaching into messages from external packages (google.type, third-party protos) whose enum definitions weren't passed to protoc; renamed/moved enums with stale references; generating OpenAPI from a subset of files.","solutions":["Include the proto file that defines the enum (and its transitive deps) in the protoc invocation.","Verify the enum name/path in the referencing proto matches the actual definition.","Regenerate all descriptors together so registry entries for the enum exist.","As a last resort, avoid exposing that enum-typed field in query parameters (restructure the nested message path)."],"exampleFix":"// before\nprotoc --openapiv2_out=. service.proto  # service.proto uses enums from types.proto\n\n// after\nprotoc -I . --openapiv2_out=. service.proto types.proto","handlingStrategy":"validation","validationCode":"// Check the enum is resolvable before doc generation:\nif _, err := reg.LookupEnum(\"\", \"my.pkg.MyEnum\"); err != nil {\n    return fmt.Errorf(\"enum %s not registered; add its file to protoc args\", \"my.pkg.MyEnum\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Include every proto defining enums referenced by query parameters in protoc args.","Use a descriptor-set build that always bundles all dependencies.","Fail fast in CI by generating docs for the full API surface."],"tags":["codegen","openapi","enum-lookup","proto-registry"],"backgroundTag":"proto-type-not-found","analyzedSha":"a58a4436a376a4bcc7d8f10c4d4f919a8438bba9","analyzedAt":"2026-09-02T10:28:31.537Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}