Skip to content

fix: keep field metadata of oneof variants - #54

Merged
kafkiansky merged 1 commit into
0.6.xfrom
fix/oneof-variant-field-metadata
Nov 23, 2026
Merged

kafkiansky merged 1 commit into
0.6.xfrom
fix/oneof-variant-field-metadata

Conversation

@kafkiansky

Copy link
Copy Markdown
Contributor

The synthetic field a variant class is generated from dropped the features and the default value of the declared field:

  • editions: a DELIMITED message variant was generated as a length-prefixed message instead of being reported, and a declared [default] of a variant was ignored;
  • proto2: a scalar or enum variant was nullable, while in proto3 and editions it is not. A null inside a variant was not written at all, so the oneof was lost on the wire.

The variant field is now the declared field without the oneof index, and it is never made nullable for presence: scalars and enums get the zero or the declared default in every syntax. Message variants stay nullable as before.

The synthetic field a variant class is generated from dropped the
features and the default value of the declared field:

- editions: a DELIMITED message variant was generated as a
  length-prefixed message instead of being reported, and a declared
  [default] of a variant was ignored;
- proto2: a scalar or enum variant was nullable, while in proto3 and
  editions it is not. A null inside a variant was not written at all,
  so the oneof was lost on the wire.

The variant field is now the declared field without the oneof index,
and it is never made nullable for presence: scalars and enums get the
zero or the declared default in every syntax. Message variants stay
nullable as before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@kafkiansky kafkiansky self-assigned this Nov 23, 2026
@kafkiansky kafkiansky added the bug Something isn't working label Nov 23, 2026
@kafkiansky
kafkiansky merged commit 0d36eb2 into 0.6.x Nov 23, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant