Skip to content

logger: conflict in protobuf field option IDs due to usage of reserved ID range #1350

@ds8088

Description

@ds8088

Hi!

I have encountered an issue while importing two seemingly unrelated packages:

  • github.com/livekit/protocol (v1.43.4);
  • go.etcd.io/etcd/client/v3 (v3.6.7).

Problem

If both packages are imported in a dummy program, it exits with a panic message:

panic: proto: extension number 50001 is already registered on message google.protobuf.FieldOptions

Root cause

The root cause on LiveKit's end seems to be the recent introduction of two new Protobuf custom options in PRs #1284 and #1308.

IDs for both custom options should have been reserved beforehand in Protobuf's Global Extension Registry.

In addition, according to the Protobuf docs, private ID range (50000-99999) should only be used for private packages, due to the aforementioned conflict risk.

etcd is also partly to blame. However, etcd has kept its usage of private option ID 50001 for more than 4 years, and maintainers do not seem to take any action: etcd-io/etcd#13216 (comment)

Reproduction

package main

import (
	_ "github.com/livekit/protocol/livekit"
	_ "go.etcd.io/etcd/client/v3"
)

func main() {
	// Panics due to the Protobuf extension number conflict.
}

Workarounds

Several workarounds are possible:

  • setting an environment variable GOLANG_PROTOBUF_REGISTRATION_CONFLICT to ignore;
  • using Go linker options to set private variable google.golang.org/protobuf/reflect/protoregistry.conflictPolicy to ignore;
  • using go:linkname to override the conflictPolicy variable.

All of these workarounds introduce unnecessary complexity in contrary with Go's ease of use. go:linkname may also be finicky due to the fact that we will have to somehow ensure our init(), which changes the linked variable at runtime, gets called before any other packages.

Resolution

I believe that the right cause of action would be to file an issue to the Protobuf team, reserve an extension number (or a small range of extension numbers) and switch the existing private IDs 50001 and 50002 for the newly reserved ones.

Thanks!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions