Buf build reports adding "optional" as breaking change
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: https://github.com/protocolbuffers/protobuf/issues/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
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 https://github.com/bufbuild/buf/pull/1978
Closing this as a "duplicate" of https://github.com/bufbuild/buf/issues/2393 - subscribe to that issue to follow along on our progress, they're both the same issue effectively.