Skip to content

Disallow options that use message-set-wire-format if Protobuf runtime can't support them#284

Merged
jhump merged 2 commits intomainfrom
jh/disallow-message-set-options-if-not-supportable
Apr 19, 2024
Merged

Disallow options that use message-set-wire-format if Protobuf runtime can't support them#284
jhump merged 2 commits intomainfrom
jh/disallow-message-set-options-if-not-supportable

Conversation

@jhump
Copy link
Member

@jhump jhump commented Apr 18, 2024

The protobuf-go runtime currently only supports message set wire format when built with the protolegacy build tag. Most users don't use this tag, but protocompile allows sources to be processed that define messages with this legacy feature.

The problem arises if a custom option refers to such a message: in that case, the resulting descriptors returned by protocompile will not be serializable. Since the protobuf-go runtime doesn't support message set wire format, it will serialize the options as if they were normal wire format messages, which will be incorrect.

So this module now checks, at init time, if the protobuf-go dependency supports message set wire format (by trying to create a very simple file descriptor that uses it). If it does not, it will report an error when interpreting options if any option tries to use message set wire format.

@jhump jhump requested a review from pkwarren April 18, 2024 21:04
@jhump jhump merged commit 5fa4f14 into main Apr 19, 2024
@jhump jhump deleted the jh/disallow-message-set-options-if-not-supportable branch April 19, 2024 17:01
kralicky pushed a commit to kralicky/protocompile that referenced this pull request May 19, 2024
… can't support them (bufbuild#284)

The protobuf-go runtime currently only supports message set wire format
when built with the `protolegacy` build tag. Most users don't use this
tag, but protocompile allows sources to be processed that define
messages with this legacy feature.

The problem arises if a custom option refers to such a message: in that
case, the resulting descriptors returned by protocompile will not be
serializable. Since the protobuf-go runtime doesn't support message set
wire format, it will serialize the options as if they were normal wire
format messages, which will be incorrect.

So this module now checks if the protobuf-go dependency supports
message set wire format (by trying to create a very simple file
descriptor that uses it). If it does not, it will report an error when
interpreting options if any option tries to use message set wire format.

(cherry picked from commit 5fa4f14)
kralicky pushed a commit to kralicky/protocompile that referenced this pull request Jun 8, 2024
… can't support them (bufbuild#284)

The protobuf-go runtime currently only supports message set wire format
when built with the `protolegacy` build tag. Most users don't use this
tag, but protocompile allows sources to be processed that define
messages with this legacy feature.

The problem arises if a custom option refers to such a message: in that
case, the resulting descriptors returned by protocompile will not be
serializable. Since the protobuf-go runtime doesn't support message set
wire format, it will serialize the options as if they were normal wire
format messages, which will be incorrect.

So this module now checks if the protobuf-go dependency supports
message set wire format (by trying to create a very simple file
descriptor that uses it). If it does not, it will report an error when
interpreting options if any option tries to use message set wire format.

(cherry picked from commit 5fa4f14)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants