-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Protocol Buffers Handbook
By :

Protobuf has a concept called reserved tags. This means that these tags are made unusable by developers when they are updating a message. This looks like this:
message Id { reserved 1; }
In this case, tag 1 isn’t reusable. This might not be directly clear how, but this helps with the problems that we saw in the previous section. Let’s see how.
If you recall the problem of integer overflow, we had a value of 4,294,967,297 encoded and Protobuf, after decoding, returned a value equal to 1. This problem came from the fact that we changed the type of the value field from uint32 to uint64 and we are now trying to encode an uint64 in an uint32. While this did not crash and the value
field was populated with data, in most cases, we won’t want the overflow behavior. This might lead to getting the wrong data for a user, overwriting data that is not from the user, and more.
To prevent this, instead of directly changing...