IMPORTANT BREAKING CHANGE
An encoding error was identified for int32
protobuf fields. Any other fields (sint32
, uint32
, ...) are not concerned.
The problem
I assumed wrongly that protobuf would chooses the smallest representation for int32 fields, but the specification is clear: int32 fields are actually encoded as int64 fields in the wire format. This means that negative values are encoded with 10 bytes, not 5. Sadly, zig-protobuf was encoding with 5 bytes, which meant that other (and more correct) implementations of protobuf would not decode them as their actual values.
If you have int32
fields in your proto messages
If your software only communicates with another zig-protobuf implementation
Update zig-protobuf to this version or up on all your systems.
If your software sends int32
data to another implementation
Check if your messages have used negative values, ensure the other system did not have any problem.
If negative values were never used, you do not have any problem. Update zig-protobuf asap.
If your software receives int32
from another implementation
Negatives values would have not been properly decoded and an error would have been returned. You probably would have noticed already.
If you have saved to disk/database encoded protobuf data with int32
fields that could contain negative values
first: backup everything.
then let's say you have this .proto file
message AnExample{
int32 a_field = 1;
}
- Create a new recovery .protofile with equivalent fields but
int32
are nowint64
message AnExampleForRecovery{
int64 a_field = 1;
}
- read from disk/database the data using the old zig-protobuf, and save it back using the new recovery message.
- update zig-protobuf
- read from disk/database with the fixed zig-protobuf and the new recovery message, save it with your original .proto message
If you don't know what to do
I'll do my best to give some support for people who could have been affected. I can be contacted in the discussions on this repository, or you can find me on the official zig discord server.
Changelog
Note: json is a work in progress subject, consider it beta.
What's Changed
- Change std.debug.print -> std.log.warn by @Detegr in #51
- JSON (de)serialization by @librolibro in #49
- Allow for external protoc by @BonusPlay in #66
- 56 Errors with
Unknown field received in ....
by @Arwalk in #63 - fix: memory leak when decoding Lists of Bytes by @kantai-chris in #68
- Fix: prevent unsafe cast on decoding by @AlpaGit in #72
- #74
dupe()
methods fail to compile by @Arwalk in #75 - fix: Convert OOB enums from panics to runtime errors by @hans-tvs in #76
- 84
encode()
fails to compile by @Arwalk in #85 - Fix integer encoding by @Arwalk in #86
New Contributors
- @Detegr made their first contribution in #51
- @librolibro made their first contribution in #49
- @BonusPlay made their first contribution in #66
- @kantai-chris made their first contribution in #68
Full Changelog: v1.0.6...v2.0.0