Proto namespace conflict

I’m trying to add V4 support to a webhook service, which already has V3 support. I’ve added the V4 handler and proto unmarshaller as described in HTTP - ChirpStack open-source LoRaWAN® Network Server documentation.

When trying to compile I’m getting the following error:

GOROOT=/home/jpmeijers/sdk/go1.19.3 #gosetup
GOPATH=/home/jpmeijers/go #gosetup
/home/jpmeijers/sdk/go1.19.3/bin/go build -o /home/jpmeijers/.cache/JetBrains/GoLand2023.3/tmp/GoLand/___go_build_ttnmapper_ingress_api . #gosetup
/home/jpmeijers/.cache/JetBrains/GoLand2023.3/tmp/GoLand/___go_build_ttnmapper_ingress_api
panic: proto: file "common/common.proto" is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict


goroutine 1 [running]:
google.golang.org/protobuf/reflect/protoregistry.glob..func1({0x13fb440?, 0xc000265110?}, {0x13fb440?, 0xc000265110})
        /home/jpmeijers/GolandProjects/ttnmapper-ingress-api/vendor/google.golang.org/protobuf/reflect/protoregistry/registry.go:56 +0x1ee
google.golang.org/protobuf/reflect/protoregistry.(*Files).RegisterFile(0xc0000121f8, {0x1414d80?, 0xc000274540?})
        /home/jpmeijers/GolandProjects/ttnmapper-ingress-api/vendor/google.golang.org/protobuf/reflect/protoregistry/registry.go:130 +0x39f
google.golang.org/protobuf/internal/filedesc.Builder.Build({{0xfc99e8, 0x31}, {0x1c69d00, 0x636, 0x636}, 0x9, 0x4, 0x0, 0x0, {0x1402cd0, ...}, ...})
        /home/jpmeijers/GolandProjects/ttnmapper-ingress-api/vendor/google.golang.org/protobuf/internal/filedesc/build.go:112 +0x1d6
google.golang.org/protobuf/internal/filetype.Builder.Build({{{0xfc99e8, 0x31}, {0x1c69d00, 0x636, 0x636}, 0x9, 0x4, 0x0, 0x0, {0x0, ...}, ...}, ...})
        /home/jpmeijers/GolandProjects/ttnmapper-ingress-api/vendor/google.golang.org/protobuf/internal/filetype/build.go:138 +0x1b8
github.com/chirpstack/chirpstack/api/go/v4/common.file_common_common_proto_init()
        /home/jpmeijers/GolandProjects/ttnmapper-ingress-api/vendor/github.com/chirpstack/chirpstack/api/go/v4/common/common.pb.go:1075 +0x1d8
github.com/chirpstack/chirpstack/api/go/v4/common.init.0()
        /home/jpmeijers/GolandProjects/ttnmapper-ingress-api/vendor/github.com/chirpstack/chirpstack/api/go/v4/common/common.pb.go:1006 +0x17

Process finished with the exit code 2

As per the Go FAQ, I tried moving the V3 and V4 handlers into separate packages, but I’m still getting this same error.

Does anyone have a suggestion how to solve this error properly, without resorting to using
go build -ldflags "-X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn"
or
GOLANG_PROTOBUF_REGISTRATION_CONFLICT=warn ./main ?

My code can be found at GitHub - ttnmapper/ingress-api at feature/chirpstackV4

Update

When compiling the service with google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn the output looks much different, mentioning many more protos colliding. So far the unmarshalling does seem to work correctly.

GOROOT=/home/jpmeijers/sdk/go1.19.3 #gosetup
GOPATH=/home/jpmeijers/go #gosetup
/home/jpmeijers/sdk/go1.19.3/bin/go build -ldflags -X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn -o /home/jpmeijers/.cache/JetBrains/GoLand2023.3/tmp/GoLand/___1go_build_ttnmapper_ingress_api . #gosetup
/home/jpmeijers/.cache/JetBrains/GoLand2023.3/tmp/GoLand/___1go_build_ttnmapper_ingress_api
WARNING: proto: file "common/common.proto" is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.LocationSource
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.GEO_RESOLVER_WIFI
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.GEO_RESOLVER_GNSS
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.GEO_RESOLVER_RSSI
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.GEO_RESOLVER_TDOA
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.CONFIG
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.GPS
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.UNKNOWN
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.MType
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.Region
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.ISM2400
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.RU864
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.IN865
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.KR920
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.AS923_4
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.AS923_3
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.AS923_2
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.AS923
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.CN470
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.AU915
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.EU433
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.CN779
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.US915
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.EU868
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.Modulation
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.LR_FHSS
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.FSK
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.LORA
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.KeyEnvelope
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "common/common.proto" has a name conflict over common.Location
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message common.Location is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message common.KeyEnvelope is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.TxAckStatus
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.INTERNAL_ERROR
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.QUEUE_FULL
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.GPS_UNLOCKED
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.TX_POWER
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.TX_FREQ
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.COLLISION_BEACON
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.COLLISION_PACKET
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.TOO_EARLY
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.TOO_LATE
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.OK
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.IGNORED
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.CRCStatus
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.CRC_OK
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.BAD_CRC
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.NO_CRC
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.FineTimestampType
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.PLAIN
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.ENCRYPTED
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.NONE
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.DownlinkTiming
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.GPS_EPOCH
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.DELAY
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.IMMEDIATELY
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.ConnState
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.RawPacketForwarderCommand
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.RawPacketForwarderEvent
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.GatewayCommandExecResponse
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.GatewayCommandExecRequest
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.ChannelConfiguration
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.GatewayConfiguration
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.DownlinkFrameItem
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.DownlinkFrame
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.UplinkFrameSet
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.UplinkFrame
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.GPSEpochTimingInfo
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.DelayTimingInfo
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.ImmediatelyTimingInfo
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.PerModulationCount
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.GatewayStats
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.PlainFineTimestamp
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.EncryptedFineTimestamp
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "gw/gw.proto" has a name conflict over gw.Modulation
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message gw.Modulation is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message gw.EncryptedFineTimestamp is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message gw.PlainFineTimestamp is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message gw.GatewayStats is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message gw.PerModulationCount is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message gw.ImmediatelyTimingInfo is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message gw.DelayTimingInfo is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message gw.GPSEpochTimingInfo is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message gw.UplinkFrame is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message gw.UplinkFrameSet is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message gw.DownlinkFrame is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message gw.DownlinkFrameItem is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message gw.GatewayConfiguration is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message gw.ChannelConfiguration is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message gw.GatewayCommandExecRequest is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message gw.GatewayCommandExecResponse is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message gw.RawPacketForwarderEvent is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message gw.RawPacketForwarderCommand is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message gw.ConnState is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "integration/integration.proto" has a name conflict over integration.DOWNLINK_GATEWAY
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "integration/integration.proto" has a name conflict over integration.UPLINK_MIC
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "integration/integration.proto" has a name conflict over integration.OTAA
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "integration/integration.proto" has a name conflict over integration.DOWNLINK_CODEC
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "integration/integration.proto" has a name conflict over integration.UPLINK_CODEC
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "integration/integration.proto" has a name conflict over integration.DOWNLINK_PAYLOAD_SIZE
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "integration/integration.proto" has a name conflict over integration.UNKNOWN
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "integration/integration.proto" has a name conflict over integration.IntegrationEvent
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "integration/integration.proto" has a name conflict over integration.LocationEvent
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "integration/integration.proto" has a name conflict over integration.StatusEvent
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "integration/integration.proto" has a name conflict over integration.TxAckEvent
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "integration/integration.proto" has a name conflict over integration.AckEvent
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "integration/integration.proto" has a name conflict over integration.JoinEvent
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "integration/integration.proto" has a name conflict over integration.UplinkEvent
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message integration.UplinkEvent is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message integration.JoinEvent is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message integration.AckEvent is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message integration.TxAckEvent is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message integration.StatusEvent is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message integration.LocationEvent is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: message integration.IntegrationEvent is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

This is a longstanding issue with protobuf:

It’s not just the namespace conflicting, it goes all the way down to the filename itself, which most people agree is pretty dumb.

I work around this in my own code when integrating with other proto packages by prefixing all my files with something unique-ish, like company name:

common/mycompany_datapoint.proto

However, in this case you’re hitting collisions due to two different versions of ChirpStack. I don’t think there’s an obvious solution here, other than to not use both, or move their use to separate binaries (may not be possible).

In the future, it would be nice if @brocaar made the filenames more unique.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.