googleapis / google-cloud-php

Google Cloud Client Library for PHP
https://cloud.google.com/php/docs/reference
Apache License 2.0
1.09k stars 436 forks source link

[Cloud Channel API] - Error in Channel Service Lib on createEntitlement method #5283

Open bshaffer opened 2 years ago

bshaffer commented 2 years ago

A customer has reported an error when using this codelab: https://cloud.google.com/channel/docs/codelabs/workspace/provisioning

They are getting an error at step 4: Create a Google Workspace entitlement

// This call returns a long-running operation.
$operation = $client->createEntitlement(
  $customer->getName() /* parent */,
  new Channel\V1\Entitlement([
    'offer' => $selectedOffer->getName(),
    'parameters' => [
      new Channel\V1\Parameter([
        // Setting 5 seats for this Annual offer
        'name' => 'num_units',
        'value' => new Channel\V1\Value([
          'int64_value' => 5,
        ])
      ]),
    ],
    'commitment_settings' => new Channel\V1\CommitmentSettings([
      // Setting renewal settings to auto renew
      'renewal_settings' => new Channel\V1\RenewalSettings([
        'enable_renewal' => true,
        'payment_plan' => Channel\V1\PaymentPlan::COMMITMENT,
        'payment_cycle' => new Channel\V1\Period([
          'duration' => 1,
          'period_type' => Channel\V1\PeriodType::YEAR,
        ]),
      ]),
    ]),
    // A string of up to 80 characters.
    // We recommend using an internal transaction ID or
    // identifier for the customer in this field.
    'purchase_order_id' => 'A codelab test'
  ])
);

// Wait for the long-running operation and get the result.
$operation->pollUntilComplete();
$entitlement = $operation->getResult();
print '=== Created entitlement' . PHP_EOL;
print $entitlement->serializeToJsonString() . PHP_EOL;

The error they are getting is

Fatal Error: Uncaught Google\Protobuf\Internal\GPBDecodeException: Error occurred during parsing: Class com.google.cloud.channel.common.errordetails.ErrorDescription hasn't been added to the descriptor pool in Google\Protobuf\Internal\Message.php:1338

They were able to follow the codelab steps until this createEntitlement piece. The error is 100% consistent and they have tried in 6 different build environments.

dwsupplee commented 2 years ago

Do we know what version of the client library they were using?

houdf0627 commented 2 years ago

After multiple rounds of test the partner was able to successfully complete the test and didn't see this error. The version tested was v0.6.4 and v0.6.5 (most of the tests were on v0.6.5). It looks like the exception happens when the plan is invalid for the customer and there isn't a proper error handling for the case then this exception was thrown.