-
Notifications
You must be signed in to change notification settings - Fork 73
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
protobuf: recognize tag alter modification #821
Conversation
93b90e7
to
3447697
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, understood the implementation by reading the protobuf doc. Leaving inlined the doc as reference to understand the implementation.
- From the protobuf doc on common errors:
renumbering fields (sometimes done to achieve a more aesthetically pleasing number order for fields). Renumbering effectively deletes and re-adds all the fields involved in the renumbering, resulting in incompatible wire-format changes.
- And also, under the message structure description:
Message Structure
A protocol buffer message is a series of key-value pairs. The binary version of a message just uses the field’s number as the key – the name and declared type for each field can only be determined on the decoding end by referencing the message type’s definition (i.e. the .proto file). Protoscope does not have access to this information, so it can only provide the field numbers.
When a message is encoded, each key-value pair is turned into a record consisting of the field number, a wire type and a payload. The wire type tells the parser how big the payload after it is. This allows old parsers to skip over new fields they don’t understand. This type of scheme is sometimes called Tag-Length-Value, or TLV.
Other that that I have a couple of doubts/requests that I've left as comment to the review.
Thanks for you work! Great job 😄
3447697
to
ddc3ddb
Compare
ddc3ddb
to
d9ab8db
Compare
About this change - What it does
This PR introduces a new
FIELD_TAG_ALTER
modification in order to recognize tag change of fields.Why this way
Changing the tag of a field is not backwards compatible but currently goes unnoticed because fields are compared by tag and not by field name. Because of this compatibility check will only recognize
FIELD_NAME_ALTER
modification which is backward compatible. This PR changes this so that if field name exists in both schemas it will compare the tags and addFIELD_TAG_ALTER
modification if the tags don't match.