Closed Markle-ddp closed 2 years ago
I had the same problem recently.
I upgraded one project to v2 and had a dependency on v1, had to upgrade also to v2 and the problem was solved.
Not much we can do with this sort of bug report. Could you share a minimal reproducible example that triggers the panic?
If I remember correctly I had my main project on grpc-gateway@v1 and a dependency, also mine, in grpc-gateway@v2
Remember having the same error. When I did a quick search I found:
package grpc.gateway.protoc_gen_swagger.options;
declares extension as 1042
and
package grpc.gateway.protoc_gen_openapiv2.options:
declares extension as 1042
I thought it may cause a problem and after 5 minutes decided best to to upgrade also. Problem solved.
Maybe is another thing...
Good Luck!
I also have the same issue. Any updates yet please?
panic: proto: extension number 1042 is already registered on message google.protobuf.FileOptions
See https://developers.google.com/protocol-buffers/docs/reference/go/faq#namespace-conflict
goroutine 1 [running]:
google.golang.org/protobuf/reflect/protoregistry.glob..func1(0x7f38f22509d8, 0x1dad8a0, 0x158dce0, 0xc00028b060, 0x1dad8a0)
/home/thangld/go/pkg/mod/google.golang.org/protobuf@v1.26.0/reflect/protoregistry/registry.go:54 +0x25f
google.golang.org/protobuf/reflect/protoregistry.(*Types).RegisterExtension(0xc00011b6e0, 0x15ba580, 0x1dad880, 0x0, 0x0)
/home/thangld/go/pkg/mod/google.golang.org/protobuf@v1.26.0/reflect/protoregistry/registry.go:541 +0x69c
google.golang.org/protobuf/internal/filetype.Builder.Build(0x1267d03, 0x46, 0x1d5cfc0, 0x37d, 0x37d, 0x0, 0x5, 0x0, 0x0, 0x15af0c0, ...)
/home/thangld/go/pkg/mod/google.golang.org/protobuf@v1.26.0/internal/filetype/build.go:237 +0xfdc
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options.file_protoc_gen_openapiv2_options_annotations_proto_init()
/home/thangld/go/pkg/mod/github.com/grpc-ecosystem/grpc-gateway/v2@v2.5.0/protoc-gen-openapiv2/options/annotations.pb.go:231 +0x1b8
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options.init.0()
/home/thangld/go/pkg/mod/github.com/grpc-ecosystem/grpc-gateway/v2@v2.5.0/protoc-gen-openapiv2/options/annotations.pb.go:212 +0x25
Process finished with exit code 2
What are you running when this happens?
It has been brought to my attention that this happens if you depend on both protoc-gen-swagger
and protoc-gen-openapiv2
generated files at the same time. Unfortunately, this is not possible, and you will have to figure out what part of your application is pulling in a dependency on the v1
branch, and try to remove it so that you can use v2
(master
) throughout.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
panic: proto: extension number 1042 is already registered on message google.protobuf.FileOptions See https://developers.google.com/protocol-buffers/docs/reference/go/faq#namespace-conflict
goroutine 1 [running]: google.golang.org/protobuf/reflect/protoregistry.glob..func1(0x1055a0b98, 0x104a24920, 0x103d13ff8, 0x1400030f7f0, 0x104a24920) /Users/mia/go/pkg/mod/google.golang.org/protobuf@v1.26.0/reflect/protoregistry/registry.go:54 +0x20c google.golang.org/protobuf/reflect/protoregistry.(*Types).RegisterExtension(0x14000197590, 0x103d51ae8, 0x104a24900, 0x0, 0x0) /Users/mia/go/pkg/mod/google.golang.org/protobuf@v1.26.0/reflect/protoregistry/registry.go:541 +0x568 github.com/golang/protobuf/proto.RegisterExtension(...) /Users/mia/go/pkg/mod/github.com/golang/protobuf@v1.5.2/proto/registry.go:279 github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options.init.0() /Users/mia/go/pkg/mod/github.com/grpc-ecosystem/grpc-gateway@v1.15.3-0.20201011140909-bb9b89ea8ac0/protoc-gen-swagger/options/annotations.pb.go:70 +0x4c exit status 2
google.golang.org/protobuf v1.26.0