-
Notifications
You must be signed in to change notification settings - Fork 37
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
Enums in proto files fail. #611
Comments
@maurogonzalez, could you clarify where you are seeing this error? It looks like the mu client is succeeding. I also successfully tested the mu client with your code. Are you seeing the error in your go client? Or elsewhere? |
@toddburnside Sorry for the late response. I didn't update the README but to get the behavior:
Current behavior:
|
@maurogonzalez OK, I see what you mean, now. It appears that no matter what the client sends to the server, the server sees |
It turns out the server is also seeing the first enum in alphabetic order. So, if you have enum values of |
I haven't had much time to investigate deeply, sorry. Thanks @toddburnside ! |
I did some more investigating. It turns out PBDirect doesn't work properly with the code generated for the enums. Given this definition in the .proto file:
The following scala code is generated: sealed trait Test
object Test {
case object LATER extends Test
case object HELLO extends Test
case object GOODBYE extends Test
case object HI extends Test
} Although PBDirect has code for handling coproducts via shapeless, and doesn't complain about this encoding, it appears to always send an empty field over the wire for them. I'm uncertain why this results in them being deserialized into the cast object with the smallest value in alphabetic order ( Looking at the tests for enums in PBDirect here, it appears that PBDirect uses some extra traits when encoding protobuf enums. If I change the scala code to the following, everything works as expected. sealed trait Test extends Pos
object Test {
case object LATER extends Test with Pos._0
case object HELLO extends Test with Pos._1
case object GOODBYE extends Test with Pos._2
case object HI extends Test with Pos._5
} I think that extending Anyone have any thoughts on this? |
higherkindness/skeuomorph#100 was created to continue discussion on this issue. |
It's worth noting that #606 depends on us being able to pick the "Zero" element for enum defaults. Per the protobuf docs:
|
This issue should be fixed in the latest version (v0.20.1) of mu-scala. We've largely rewritten the protobuf serialization library and fixed a lot of bugs, as well as improving support for protobuf enums. The mu-scala codegen will now encode enums in Scala as enumeratum If you have any more problems with enums, please open a new issue. |
Testing enum types in proto messages I got the following errors:
https://github.com/maurogonzalez/rpctest/tree/enums
Using protocol.proto
And
srcGen
to generate scala code.The text was updated successfully, but these errors were encountered: