buf icon indicating copy to clipboard operation
buf copied to clipboard

FIELD_SAME_ONEOF is not triggering

Open MollardMichael opened this issue 1 year ago • 3 comments

I might have missunderstood the usage of FIELD_SAME_ONEOF as a breaking rule.

My understanding was that it would trigger as long as I add or remove a new field in a oneof .

So I tried the following

     oneof statusInfo {
         Booked booked = 100;
+        Booked booked_2 = 101;
     }

Using buf version 1.30.1.

I was expecting it to trigger the rule but it is not. Am I doing something wrong?

My buf.yaml

version: v1
lint:
  use:
    - DEFAULT
breaking:
  use:
    - WIRE

MollardMichael avatar Apr 10 '24 03:04 MollardMichael

FIELD_SAME_ONEOF will trigger when the same tag is moved out (or in) of the oneof. So:

     oneof statusInfo {
         Booked booked = 100;
-       Booked booked_2 = 101;
     }
+   Booked booked_2 = 101;

See the details on oneof rules: proto3

emcfarlane avatar Apr 10 '24 18:04 emcfarlane

Is there anyway to detect changes on oneof?

It's can be quite breaking

MollardMichael avatar Apr 17 '24 09:04 MollardMichael

Adding fields is not a breaking change and part of the benefits. Maybe you could explain what you are hoping to achieve or what issues you are having?

emcfarlane avatar Apr 18 '24 15:04 emcfarlane

While it's not breaking the message itself, it make the consumer unable to understand it. (Consumer needs to be updated before the producer can use this new field). I'd like to be able to be warned about that one way or another I guess

MollardMichael avatar May 09 '24 01:05 MollardMichael

Adding a new field to a oneof isn't something we would consider breaking, and the buf CLI takes a strict stance that it only will print errors from buf lint or buf breaking, and won't consider warnings of advisories. Users need to know that if buf lint or buf breaking prints an error, it really is an error, and it can't be ignored base on their configuration. Warnings result in low signal-to-noise ratio that result in them just being ignored. Going to close this issue, but thanks for the feedback.

bufdev avatar May 18 '24 22:05 bufdev