Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buf breaking - Better UX around proto3 optional fields #2393

Open
rodaine opened this issue Aug 22, 2023 · 1 comment
Open

buf breaking - Better UX around proto3 optional fields #2393

rodaine opened this issue Aug 22, 2023 · 1 comment
Labels
Cleanup Cleanup tasks

Comments

@rodaine
Copy link
Member

rodaine commented Aug 22, 2023

Running breaking change detection with FILE rules, if a proto3 optional field is moved into a oneof, buf breaking correctly identifies the incompatible change, however the error messages can be a bit confusing unless someone is aware of the implementation of optionals (i.e., via a synthetic oneof).

For a message:

message Msg {
  optional int32 foo = 1;
}

... changing it to:

message Msg {
  oneof bar {
    int32 foo = 1;
  }
}

... results in the following error messages:

Error: Previously present oneof "_foo" on message "Msg" was deleted.
Error: Field "1" on message "Msg" moved from oneof "_foo" to oneof "bar".

A better message could combine the two and should probably mention the optional keyword rather than the synthetic _foo oneof:

Error: Field "1" on message "Msg" changed from optional to a member of oneof "bar"

Related: #1906

@bufdev
Copy link
Member

bufdev commented Jun 13, 2024

When we do get to this, make sure that #1906 is addressed as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cleanup Cleanup tasks
Projects
None yet
Development

No branches or pull requests

3 participants