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 build reports adding "optional" as breaking change #1906

Closed
mikhainin opened this issue Mar 10, 2023 · 2 comments
Closed

Buf build reports adding "optional" as breaking change #1906

mikhainin opened this issue Mar 10, 2023 · 2 comments
Labels
Feature New feature or request

Comments

@mikhainin
Copy link

We've got the following

$ cat cat proto/antispamtextcheck.proto
syntax = "proto3";

package com.bumble.contract.service;

message CheckTextRequest {
  int64 collective_id = 2; // we will make it "optional int64 collective_id = 2;" later
}
buf build -o old.bin proto/

If we add "optional" we will get a really confusing error:

buf breaking --against old.bin proto
proto/antispamtextcheck.proto:6:3:Field "2" on message "CheckTextRequest" moved from outside to inside a oneof.

According to protobuf folks, adding "oneof" is fine (link: protocolbuffers/protobuf#10822)

However, if we consider this as indeed a breaking change, it looks like we can detect that this is not "oneof" (which isn't clear for users) but rather the usage of field presence. So, we can change the error message to make it clear. e.g.

Field "2" on message "CheckTextRequest" became "optional" which internally moves it inside a oneof

If possible, it would be great if we could make this particular check disableable, because in our case this is absolutely fine

@bufdev
Copy link
Member

bufdev commented Apr 6, 2023

Oneofs and breaking changes are a complicated subject: https://protobuf.dev/programming-guides/proto3/#updating

In v1 of the buf breaking rules (which we are committed to not breaking), we took the simple approach and said that any changes around oneofs were both breaking for generated sources and wire compatibility. In reality, there is a bit more nuance around wire compatibility, which in a v2, we would look to clean up.

I agree that the error message could be better, and the breaking change rules that produce errors should be cleaned up here. I've attempted to address this in #1978

@bufdev
Copy link
Member

bufdev commented Jun 13, 2024

Closing this as a "duplicate" of #2393 - subscribe to that issue to follow along on our progress, they're both the same issue effectively.

@bufdev bufdev closed this as completed Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants