-
Notifications
You must be signed in to change notification settings - Fork 146
Description
Background
I work on the k3s project, which has a large dependency trail. Recently we attempted to move to a new version of spegel, which pulled in new versions of libp2p/go-libp2p-kad-dht which bumped boxo from from v0.10.0 -> v0.24.3
Issue
All these dependencies thrown together has resulted in conflicts around record.proto registration:
panic: proto: file "record.proto" is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict
Looking thru our vendor list you can see that there are a multitude of dependencies that use a very generic record.proto for some protobuf.
grep -rF 'record.proto' vendor/
vendor/go.etcd.io/etcd/server/v3/wal/walpb/record.pb.go:// source: record.proto
vendor/go.etcd.io/etcd/server/v3/wal/walpb/record.pb.go:func init() { proto.RegisterFile("record.proto", fileDescriptor_bf94fd919e302a1d) }
vendor/github.com/libp2p/go-libp2p-record/pb/record.pb.go:// source: record.proto
vendor/github.com/libp2p/go-libp2p-record/pb/record.pb.go:func init() { proto.RegisterFile("record.proto", fileDescriptor_bf94fd919e302a1d) }
vendor/github.com/libp2p/go-libp2p-record/pb/record.proto:// `protoc --gogo_out=. record.proto`
vendor/github.com/libp2p/go-libp2p-kad-dht/pb/dht.proto:import "github.com/libp2p/go-libp2p-record/pb/record.proto";
vendor/github.com/libp2p/go-libp2p/p2p/protocol/identify/pb/identify.proto: // github.com/libp2p/go-libp2p/core/peer/pb/peer_record.proto for message definitions.
vendor/github.com/libp2p/go-libp2p/p2p/protocol/identify/pb/identify.pb.go: // github.com/libp2p/go-libp2p/core/peer/pb/peer_record.proto for message definitions.
vendor/github.com/libp2p/go-libp2p/core/peer/pb/peer_record.pb.go:// source: core/peer/pb/peer_record.proto
vendor/github.com/ipfs/boxo/ipns/pb/record.pb.go:// source: record.proto
vendor/github.com/ipfs/boxo/ipns/record.go://go:generate protoc -I=pb --go_out=pb --go_opt=module=github.com/ipfs/boxo/ipns/pb pb/record.proto
Looking at the FAQ around how to resolve this that https://protobuf.dev/reference/go/faq#namespace-conflict, it seems that boxo does not define a unique enough option go_package for its protobuf. Additionally, it is likely a good idea to just change the name entirely from something so generic as record.