Azure / azure-storage-php

Microsoft Azure Storage Library for PHP
MIT License
217 stars 200 forks source link

ServiceRestProxy throws Error: Can only throw objects #259

Closed spaze closed 3 years ago

spaze commented 4 years ago

Which service(blob, file, queue, table) does this issue concern?

common

Which version of the SDK was used?

microsoft/azure-storage-common 1.5.0

What's the PHP/OS version?

PHP 7.3, something something Ubuntu

What problem was encountered?

Promises can be rejected with a $reason. Sometimes, the $reason is a string:

        if ($this->state === self::PENDING) {
            $this->reject('Invoking the wait callback did not resolve the promise');
        }

https://github.com/guzzle/promises/blob/60d379c243457e073cff02bc323a2a86cb355631/src/Promise.php#L237-L240

ServiceRestProxy expects $reason to be an exception though:

https://github.com/Azure/azure-storage-php/blob/1afd50bb3f89f1fed9de0b1edaf424f37a4bc13a/azure-storage-common/src/Common/Internal/ServiceRestProxy.php#L404-L407

If it's a string, it's not a RequestException and it's then thrown which results in an error:

Error: Can only throw objects

Stack trace:

src/Common/Internal/ServiceRestProxy.php:406
guzzlehttp/promises/src/Promise.php:203   MicrosoftAzure\Storage\Common\Internal\ServiceRestProxy->MicrosoftAzure\Storage\Common\Internal\{closure}()
guzzlehttp/promises/src/Promise.php:174   GuzzleHttp\Promise\Promise::callHandler()
promises/src/RejectedPromise.php:40   GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
guzzlehttp/promises/src/TaskQueue.php:47   GuzzleHttp\Promise\RejectedPromise::GuzzleHttp\Promise\{closure}()
guzzlehttp/promises/src/Promise.php:234   GuzzleHttp\Promise\TaskQueue->run()
guzzlehttp/promises/src/Promise.php:267   GuzzleHttp\Promise\Promise->waitIfPending()
guzzlehttp/promises/src/Promise.php:225   GuzzleHttp\Promise\Promise->invokeWaitList()
guzzlehttp/promises/src/Promise.php:62   GuzzleHttp\Promise\Promise->waitIfPending()
src/Table/TableRestProxy.php:978   GuzzleHttp\Promise\Promise->wait()
libraries/TableService/Tables.php:57   MicrosoftAzure\Storage\Table\TableRestProxy->getTable()
libraries/User/UserAccount.php:59   ReportUriIo\TableService\Tables->tableExists()
libraries/Report/Processor.php:209   ReportUriIo\User\UserAccount->isDisabled()
libraries/Report/Processor/Wizard.php:79   ReportUriIo\Report\Processor->loadConfig()
libraries/Report/Processor/Wizard.php:59   ReportUriIo\Report\Processor\Wizard->processReport()
application/controllers/Process.php:293   ReportUriIo\Report\Processor\Wizard->process()
system/core/CodeIgniter.php:532   Process->wizard()
public/index.php:324   require_once()

Steps to reproduce the issue?

I can't reproduce the issue, but the exception was thrown when we've had some connection issues to Azure caused by some DigitalOcean-Azure routing issues.

Have you found a mitigation/solution?

Not yet, but I will investigate and send a PR as usual :-) Update: as promised (no pun intended), the solution/fix is in #262.

Is there a failing request ID related to this problem returned by server? What is it?

No

What is the storage account name and time frame of your last reproduce? (UTC YYYY/MM/DD hh:mm:ss)

2020/10/08 11:24:47 UTC

XiaoningLiu commented 4 years ago

PR looks good!