-
Notifications
You must be signed in to change notification settings - Fork 13
Description
cl/603226138 has broken the GAPIC generation in the V1 clients (see googleapis/google-cloud-php#7023). Some of the changes that look wrong are:
- All RPC method arguments have been removed
- All sample arguments have been removed
- All setters used in tests have been removed
- References to resource name helpers have been removed in comments
This may be due to changes in the way the GAPIC generator locates google.api.field_behavior, which is done in FieldDetails::determineIsRequired, and is read by ProtoHelpers::getCustomOptionRaw:
gapic-generator-php/src/Utils/ProtoHelpers.php
Lines 351 to 384 in 277c703
| $values = []; | |
| if ($message->hasOptions()) { | |
| $opts = $message->getOptions(); | |
| $unknown = $messageUnknown->getValue($opts); | |
| if ($unknown) { | |
| $unknownStream = new CodedInputStream($unknown); | |
| // Read through the stream of all custom options, looking for | |
| // the requested option-id. If it's repeated, then all options | |
| // must be parsed, otherwise return the first found. | |
| while (($tag = $unknownStream->readTag()) !== 0) { | |
| $value = 0; | |
| // TODO: Handle extra option types as required. | |
| switch (GPBWire::getTagWireType($tag)) { | |
| case GPBWire::WIRETYPE_VARINT: | |
| $unknownStream->readVarint32($value); | |
| break; | |
| case GPBWire::WIRETYPE_LENGTH_DELIMITED: | |
| $len = 0; | |
| $unknownStream->readVarintSizeAsInt($len); | |
| $unknownStream->readRaw($len, $value); | |
| break; | |
| default: | |
| throw new \Exception('Cannot read option tag'); | |
| } | |
| if (GPBWire::getTagFieldNumber($tag) === $optionId) { | |
| if ($repeated) { | |
| $values[] = $value; | |
| } else { | |
| return $value; | |
| } | |
| } | |
| } | |
| } | |
| } |
Note: There may be a way to get options from UPB. However, the APIs would need to be implemented for both the pure-PHP and upb backends. The upb library itself supports it, but there is currently no glue.
UPDATE: We've been able to duplicate the error (which seems to be affecting all "repeated" custom options) by updating the protoc binary to 25.2 and running the following test:
vendor/bin/phpunit tests/Unit/Utils/ --filter testProtoCustomOptionsUPDATE 2 - If we add [packed = false] to the custom option, the previous custom option logic works as expected.