{"record":{"id":"75f01b34670e5d41","repo":"grpc-ecosystem/grpc-gateway","slug":"extension-is-t-want-an-httprule","errorCode":null,"errorMessage":"extension is %T; want an HttpRule","messagePattern":"extension is %T; want an HttpRule","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/descriptor/services.go","lineNumber":224,"sourceCode":"\t\tif err := applyOpts(opts); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn meth, nil\n}\n\nfunc extractAPIOptions(meth *descriptorpb.MethodDescriptorProto) (*options.HttpRule, error) {\n\tif meth.Options == nil {\n\t\treturn nil, nil\n\t}\n\tif !proto.HasExtension(meth.Options, options.E_Http) {\n\t\treturn nil, nil\n\t}\n\text := proto.GetExtension(meth.Options, options.E_Http)\n\topts, ok := ext.(*options.HttpRule)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"extension is %T; want an HttpRule\", ext)\n\t}\n\treturn opts, nil\n}\n\nfunc defaultAPIOptions(svc *Service, md *descriptorpb.MethodDescriptorProto) (*options.HttpRule, error) {\n\t// FQSN prefixes the service's full name with a '.', e.g.: '.example.ExampleService'\n\tfqsn := strings.TrimPrefix(svc.FQSN(), \".\")\n\n\t// This generates an HttpRule that matches the gRPC mapping to HTTP/2 described in\n\t// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests\n\t// i.e.:\n\t//   * method is POST\n\t//   * path is \"/<service name>/<method name>\"\n\t//   * body should contain the serialized request message\n\trule := &options.HttpRule{\n\t\tPattern: &options.HttpRule_Post{\n\t\t\tPost: fmt.Sprintf(\"/%s/%s\", fqsn, md.GetName()),\n\t\t},","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/grpc-ecosystem/grpc-gateway/blob/a58a4436a376a4bcc7d8f10c4d4f919a8438bba9/internal/descriptor/services.go#L206-L242","documentation":"Type-assertion error in extractAPIOptions: the google.api.http extension present on a MethodOptions did not unmarshal/decode into *options.HttpRule (ext holds some other message type). Since proto.GetExtension returned an unexpected concrete type, the method's HTTP options cannot be read and loadServices fails.","triggerScenarios":"Thrown at internal/descriptor/services.go:224 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Regenerate/recompile descriptors so google.api.http is linked to the correct HttpRule type.","Ensure the .proto imports google/api/annotations.proto and the extension value is actually an HttpRule.","Check for descriptor corruption or mismatched protoc/plugin versions."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a58a4436a376a4bcc7d8f10c4d4f919a8438bba9","analyzedAt":"2026-09-02T10:28:31.537Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}