serializeToJsonString prints the wrong enum value name
PierrickVoulet opened this issue · comments
What version of protobuf and what language are you using?
Version: php-upb-msg (protobuf2)
Language: PHP
What operating system (Linux, Windows, ...) and version?
Linux 5.2.17-1rodete3-amd64 x86_64
What runtime / compiler are you using (e.g., python version or gcc version)
PHP Extension (C implementation)
What did you do?
Run the following script (some proto messages are defined here):
<?php
$errorCode = new \Google\Ads\GoogleAds\V3\Errors\ErrorCode([
'authentication_error' => \Google\Ads\GoogleAds\V3\Errors\AuthenticationErrorEnum\AuthenticationError::AUTHENTICATION_ERROR
]);
What did you expect to see
{"authenticationError":"AUTHENTICATION_ERROR"}
What did you see instead?
{"authenticationError":"UNSPECIFIED"}
Anything else we should know about your project / environment
None.
I am having trouble reproducing this. I tried creating the same setup in the protobuf unit tests but the JSON output was as expected: eeab3d1
Can you give me a full setup to reproduce this, or add a test to the protobuf test suite that reproduces it?
Thanks for the repro! This turned out to be a deep bug in upb's data representation layer. Oneof cases were getting stored at the wrong offset (one byte off) and overwriting the first byte of the enum data.
This should be fixed in b15ccb0
Verified