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

Introspect message fields if the field type changes to see if the actual message types are breaking for WIRE, WIRE_JSON #2167

Closed
ParkMyCar opened this issue Jun 7, 2023 · 5 comments
Labels
Feature New feature or request

Comments

@ParkMyCar
Copy link

When detecting breaking changes the linter emits a false positive when changing the type of a mesasge. The format of our buf.yaml is:

version: v1
breaking:
  use:
    - WIRE

Example

Say you have the protobuf message:

message Error {
  oneof kind {
    google.protobuf.Empty overflow = 1;
  }
}

and you change it to:

message Error {
  message OverflowValue {
    string value = 1;
  }

  oneof kind {
    OverflowValue overflow = 1;
  }
}

this is a wire compatible change, but buf indicates that it is not.

google.protobuf.Empty is a message with zero fields, and OverflowValue is a message with one optional field. For a type originally serialized with the first version, and deserialized with the second, you'll get an OverflowValue message where the inner value field is an empty string.

Apologies if this is a duplicate issue, I searched but could not find anything 🙂

@srikrsna-buf
Copy link
Member

srikrsna-buf commented Jun 7, 2023

The rule doesn't mention anything regarding messages: https://buf.build/docs/breaking/rules/#field_wire_compatible_type. But I don't see why this shouldn't be possible for WIRE compatibility. Thank you for reporting!

@srikrsna-buf srikrsna-buf added the Bug Something isn't working label Jun 7, 2023
@bufdev bufdev removed the Bug Something isn't working label Jun 7, 2023
@bufdev
Copy link
Member

bufdev commented Jun 7, 2023

buf does not do introspection on actual message field types - buf assumes that changing the type of a field is a breaking change. We could in theory go further than this specifically for WIRE and WIRE_JSON, by saying if a given field changes between message types, running breaking change detection between them, but to be candid I don't know if we'll get to this anytime soon - generally, changing your core message type for a field is not advisable.

@bufdev bufdev changed the title linter: false positive when changing message type Introspect message fields if the field type changes to see if the actual message types are breaking for WIRE, WIRE_JSON Jun 7, 2023
@ParkMyCar
Copy link
Author

Thanks for the quick responses! 🙂

...but to be candid I don't know if we'll get to this anytime soon - generally, changing your core message type for a field is not advisable.

That's totally fair! I just wanted to call this out because it was a change that is technically wire compatible, but buf was telling me it's not

@bufdev
Copy link
Member

bufdev commented Jun 13, 2024

We're going to close this as stale, as I don't think this is an update we're going to be able to staff unfortunately. Apologies.

@bufdev bufdev closed this as completed Jun 13, 2024
@bufdev
Copy link
Member

bufdev commented Jun 13, 2024

Actually on second thought, this might be something we want to do. But going to keep this issue closed in favor of #2318.

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

No branches or pull requests

4 participants