Split FIELD_SAME_TYPE into FIELD_SAME_TYPE, FIELD_WIRE_COMPATIBLE_TYPE, FIELD_WIRE_JSON_COMPATIBLE_TYPE #400
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #80
See https://docs.buf.build/breaking-rules/#field_same_type
See https://developers.google.com/protocol-buffers/docs/proto3#updating
See https://developers.google.com/protocol-buffers/docs/proto3#json
Largely in the interest of expediency, but also in the interest of users not thinking about what is and isn't wire-compatible in terms of scalar types, we did not encode the actual wire compatibility rules when checking if a field is the same type if using the
WIRE
category. It turns out that users noticed this. There was also a legitimate case of someone moving enums from being nested to non-nested, and this being detected as a breaking change.This PR adds a new breaking rule
FIELD_WIRE_COMPATIBLE_TYPE
that replacesFIELD_SAME_TYPE
for theWIRE
category inv1
. This does the following:FIELD_WIRE_COMPATIBLE_TYPE
.This also adds a new
FIELD_WIRE_JSON_COMPATIBLE_TYPE
that replacesFIELD_SAME_TYPE
for theWIRE_JSON
category in v1.JSON still allows for some exchanging of types, but due to how various fields are serialized, the rules are stricter. See https://developers.google.com/protocol-buffers/docs/proto3#json - for example, int32, sint32, uint32 can be exchanged, but 64-bit numbers have a different representation in JSON. Since sint32 is not compatible with int32 or uint32 in WIRE, we have to limit this to allowing int32 and uint32 to be exchanged in JSON.
This does the following:
are added to failures produced from
FIELD_WIRE_JSON_COMPATIBLE_TYPE
.