haberman / protobuf

Protocol Buffers - Google's data interchange format

Home Page:https://developers.google.com/protocol-buffers/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

serializeToString fails printing an instance of LRO

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
$response = new \Google\Protobuf\GPBEmpty();
$any = new \Google\Protobuf\Any();
$any->setValue($response->serializeToString());
$lro = new \Google\LongRunning\Operation();
$lro->setResponse($any);
print $lro->serializeToString();

What did you expect to see
No PHP Fatal error.

What did you see instead?
PHP Fatal error: Uncaught Exception: Error occurred during serialization

Anything else we should know about your project / environment
None.

I'm having trouble reproducing this error. I tried creating the same pattern in 116ebc4 but this didn't throw any error.

I can trigger an error though if I change it to serializeToJSONString(). I added better reporting of JSON serialization errors in b0d4ef0 and I got:

Exception: Error occurred during JSON serialization: Bad type URL

It's true that the Any message in this case doesn't seem to have a type URL. But it should serialize fine if you are serializing to binary format.

If you are indeed serializing to binary format, I wonder if you could help me reproduce this in the protobuf tests?

I gave it another try with the latest changes: it is now fixed and verified.