exprotobuf
exprotobuf copied to clipboard
Run verify_msg before encoding
Encoding integer values of out the specified range (overflow) results in an invalid binary which crashes the decoding in a way that is very hard to troubleshoot. It's best if the encoding fails with an easy message:
** (ErlangError) Erlang error: {:gpb_type_error, {{:value_out_of_range, :unsigned, 32}, [value: 340282366920938463463374607431768211456, path: 'path_to_the_invalid_field']}}
https://github.com/tomas-abrahamsson/gpb README file states:
Gpb can optionally generate code for verification of values during encoding this makes it easy to catch e.g integers out of range, or values of the wrong type.
@bitwalker Did you have the time to take a look at this PR? Thanks!