Closed edisonywh closed 4 months ago
If this is indeed a bug I am happy to attempt to send in a PR (if someone can point me to the right place in the codebase for it that'll also help tremendously!
Hey @edisonywh thanks for reporting! No, this is not expected behaviour, definitely a bug 🙃
cc @savhappy
Hey team! I am seeing a weird behaviour when we pass in a wrong struct to a protobuf -
Protobuf.encode
encodes it just fine, but I would expect that to raise an error instead?Here's a reproduction test file.
I would expect the second test case to fail, because I am passing in
%RandomStruct{}
whereasMessage.value
, according to the protobuf, should be of typeNestedMessage
.Being able to encode
map
into a protobuf message is a good feature, but I feel like it should acceptraw map | exact struct
(so%{} | %{__struct__: NestedMessage}
in this case), and notany map
.Doc says validation is done during encoding: https://github.com/elixir-protobuf/protobuf/blob/main/README.md?plain=1#L99-L100, and I would categorise this as a "mistyped value"
Is this expected behaviour?