-
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
Proto2 required
fields that contain default values are not serialized correctly
#71
Comments
Json representation of
|
I suspect the |
Yes @garyp, Thank you very much for the pointer. It worked with Would you prefer to look into binary data still? I can try to share it. Just wondering how this works fine between java producer & java consumer and we noted this issue only now when migrating to Kotlin producer! Or I think I need to verify java to java once again whether this |
@sujithkris This seems like a bug in pbandk. That's why it works in Java 🙂 pbandk isn't doing the correct thing for proto2 required fields that contain default values. At least that's my hypothesis. If you could share the binary data, that'd help me confirm the hypothesis. But I should be able to also write a quick unit test to test this scenario. |
@garyp - Good to address the presence of default I did not get a chance to get the binary data. Let me know the best way you recommend to share the same. |
@sujithkris The JSON format is technically defined only for proto3 files. The Javadoc for the Java
While the JSON format will mostly work fine with proto2 files, there are going to be proto2-specific corner cases with undefined behavior. I wouldn't recommend using JSON with proto2 files until Google officially supports it.
It should be pretty small. So you could just base64-encode it and paste it into a comment here. |
@garyp Hi, Do we have a fix ready for |
@sujithkris I was able to reproduce the bug with a unit test. Unfortunately it doesn't look like pbandk ever properly supported Also, to clarify, the bug only impacts proto2 |
required
fields that contain default values are not serialized correctly
Also refactor some of the `hasPresence`-related code in the code generator to make it easier to understand. Fixes #71.
Also refactor some of the `hasPresence`-related code in the code generator to make it easier to understand. Fixes #71.
Also refactor some of the `hasPresence`-related code in the code generator to make it easier to understand. Fixes #71. ## Guide to changes There's a lot of noise in this PR from empty lines being added to generated code. The interesting changes are in `File.kt`, `FileBuilder.kt` and `CodeGenerator.kt` under `protoc-gen-pbandk/lib/src/commonMain/kotlin/pbandk/gen/`. You can see an example of how these changes impact the generated code in `runtime/src/commonMain/kotlin/pbandk/wkt/descriptor.kt`, where a couple `required` fields in the `NamePart` message were previously being generated incorrectly and now are handled properly. Aside from the main changes, there is also some slight refactoring of the `kotlinJavaRoundtripTest()` method used in some of the tests (and the method also got renamed to `pbandkJavaRoundtripTest()`).
Also refactor some of the `hasPresence`-related code in the code generator to make it easier to understand. Fixes #71. There's a lot of noise in this PR from empty lines being added to generated code. The interesting changes are in `File.kt`, `FileBuilder.kt` and `CodeGenerator.kt` under `protoc-gen-pbandk/lib/src/commonMain/kotlin/pbandk/gen/`. You can see an example of how these changes impact the generated code in `runtime/src/commonMain/kotlin/pbandk/wkt/descriptor.kt`, where a couple `required` fields in the `NamePart` message were previously being generated incorrectly and now are handled properly. Aside from the main changes, there is also some slight refactoring of the `kotlinJavaRoundtripTest()` method used in some of the tests (and the method also got renamed to `pbandkJavaRoundtripTest()`).
My proto is as follows
The
Update
objectprotoMarshal()
is sent across Kafka and on the consumer side, I am getting exceptions which are on java platform. The exceptions are different in different projects.Note: I am getting exception only when
Prop
containsRegularProp
.Below listed bullet points are the exception messages I am getting in java projects which deserialize using
Update.parseFrom(data)
Project - 1
Value cannot cast to Update
Project - 2
prop[0].regular_prop.is_array not present
Is this due to the presence of
Value
inRegularProp
?The same proto is used by other Kafka producers in different projects (Javascript, java, etc.) and working fine. So to repeat the exception is only for Kafka message sent from Kotlin to other platform and only when using
RegularProp
The text was updated successfully, but these errors were encountered: