Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runInstances Error:Call to undefined method Error::getResponse() in yii2 #2319

Closed
3 tasks done
alahoo opened this issue Sep 17, 2021 · 9 comments · Fixed by #2377
Closed
3 tasks done

runInstances Error:Call to undefined method Error::getResponse() in yii2 #2319

alahoo opened this issue Sep 17, 2021 · 9 comments · Fixed by #2377
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@alahoo
Copy link

alahoo commented Sep 17, 2021

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug
Call runInstances Error:Call to undefined method Error::getResponse() in yii2

Version of AWS SDK for PHP?
Version 3.194.0

Version of PHP (php -v)?
PHP 7.2.0 (cli) (built: Dec 15 2017 18:34:34) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies

To Reproduce (observed behavior)
`<?php
require(DIR . '/vendor/autoload.php');
require(DIR . '/vendor/yiisoft/yii2/Yii.php');

$config = require(DIR . '/config/web.php');
//(new yii\web\Application($config))->run();
//$yii2App = new yii\web\Application($config);

require(DIR . '/assets/inc/aws/aws-autoloader.php');

use Aws\Credentials\Credentials;
use Aws\Ec2\Ec2Client;

$credentials = new Credentials("ID","KEY");
$ec2Client = new Ec2Client([
'region' => "us-west-1",
'version' => '2016-11-15',
'credentials' => $credentials
]);
$ec2_argv = [
'MaxCount' => 2,
'MinCount' => 2,
'DryRun' => true,
'ImageId' => 'ami-xxxx',
'SubnetId' => 'subnet-xxxx',
'InstanceType' => 'c5.large',
];
$check = $ec2Client->runInstances($ec2_argv);
print_r($check);`

Screenshots

Additional context
`PHP Fatal error: Uncaught Error: Call to undefined method Error::getResponse() in /data/data/omcs/assets/inc/aws/Aws/Handler/GuzzleV6/GuzzleHandler.php:60
Stack trace:
#0 /data/data/omcs/assets/inc/aws/GuzzleHttp/Promise/Promise.php(204): Aws\Handler\GuzzleV6\GuzzleHandler::Aws\Handler\GuzzleV6{closure}(Object(Error))
#1 /data/data/omcs/assets/inc/aws/GuzzleHttp/Promise/Promise.php(153): GuzzleHttp\Promise\Promise::callHandler(2, Object(Error), NULL)
#2 /data/data/omcs/assets/inc/aws/GuzzleHttp/Promise/TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}()
#3 /data/data/omcs/assets/inc/aws/GuzzleHttp/Handler/CurlMultiHandler.php(118): GuzzleHttp\Promise\TaskQueue->run()
#4 /data/data/omcs/assets/inc/aws/GuzzleHttp/Handler/CurlMultiHandler.php(145): GuzzleHttp\Handler\CurlMultiHandler->tick()
#5 /data/data/omcs/assets/inc/aws/GuzzleHttp/Promise/Promise.php(248): GuzzleHttp\Handler\CurlMultiHandler->execute(true)
#6 /data/data/omcs/assets/inc/aws/GuzzleHttp/Promise/Promise.php(224): GuzzleHttp\Promise\Pr in /data/data/omcs/assets/inc/aws/Aws/Handler/GuzzleV6/GuzzleHandler.php on line 60

Fatal error: Uncaught Error: Call to undefined method Error::getResponse() in /data/data/omcs/assets/inc/aws/Aws/Handler/GuzzleV6/GuzzleHandler.php:60
Stack trace:
#0 /data/data/omcs/assets/inc/aws/GuzzleHttp/Promise/Promise.php(204): Aws\Handler\GuzzleV6\GuzzleHandler::Aws\Handler\GuzzleV6{closure}(Object(Error))
#1 /data/data/omcs/assets/inc/aws/GuzzleHttp/Promise/Promise.php(153): GuzzleHttp\Promise\Promise::callHandler(2, Object(Error), NULL)
#2 /data/data/omcs/assets/inc/aws/GuzzleHttp/Promise/TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}()
#3 /data/data/omcs/assets/inc/aws/GuzzleHttp/Handler/CurlMultiHandler.php(118): GuzzleHttp\Promise\TaskQueue->run()
#4 /data/data/omcs/assets/inc/aws/GuzzleHttp/Handler/CurlMultiHandler.php(145): GuzzleHttp\Handler\CurlMultiHandler->tick()
#5 /data/data/omcs/assets/inc/aws/GuzzleHttp/Promise/Promise.php(248): GuzzleHttp\Handler\CurlMultiHandler->execute(true)
#6 /data/data/omcs/assets/inc/aws/GuzzleHttp/Promise/Promise.php(224): GuzzleHttp\Promise\Pr in /data/data/omcs/assets/inc/aws/Aws/Handler/GuzzleV6/GuzzleHandler.php on line 60`

@alahoo alahoo added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 17, 2021
@SamRemis
Copy link
Member

Hi @alahoo This usually happens when the service (in this case EC2) is sending an invalid response to the SDK. Could you help me investigate by adding 'debug'=>true to your client constructor and posting the result here? It will print out a long log output, including the raw response from EC2- I believe they would send an XML error.

Please post the raw response here when you get the chance, even if that gives you enough information to solve your problem. It will help me to demonstrate to the company why we need to have more forgiving error parsers that gracefully fail, and prevent problems like this from happening in the future.

Thank you,
-Sam

$ec2Client = new Ec2Client([
'region' => "us-west-1",
'version' => '2016-11-15',
'debug' => true
'credentials' => $credentials
]);

@alahoo
Copy link
Author

alahoo commented Sep 18, 2021

Hi @alahoo This usually happens when the service (in this case EC2) is sending an invalid response to the SDK. Could you help me investigate by adding 'debug'=>true to your client constructor and posting the result here? It will print out a long log output, including the raw response from EC2- I believe they would send an XML error.

Please post the raw response here when you get the chance, even if that gives you enough information to solve your problem. It will help me to demonstrate to the company why we need to have more forgiving error parsers that gracefully fail, and prevent problems like this from happening in the future.

Thank you,
-Sam

$ec2Client = new Ec2Client([
'region' => "us-west-1",
'version' => '2016-11-15',
'debug' => true
'credentials' => $credentials
]);

PHP Fatal error: Allowed memory size of 5377097728 bytes exhausted (tried to allocate 3219472384 bytes) in /data/data/omcs/assets/inc/aws/Aws/TraceMiddleware.php on line 261
ll -sh request.log
3.0G -rw-r--r-- 1 root root 3.0G Sep 18 11:57 request.log

Sorry,It's too big

@DavidAnderson684
Copy link

@alahoo I've encountered Error:Call to undefined method Error::getResponse() also, in 3.209.26 (i.e. current release), using the S3 API. According to https://www.php.net/manual/en/class.error.php, there is no such method, so it looks like there is an issue in the SDK here?

@SamRemis
Copy link
Member

@DavidAnderson684, on a quick search, I don't believe we have any static calls in the SDK to a getResponse() method, we do have some that look similar in non-static contexts, so I'm wondering if the error you're getting is just being displayed in a confusing way. To help get to the source of this, could you give me the stack trace?

If you have steps to reproduce the issue and/or the raw response from the service which you can obtain using the debug config option mentioned above, that would be helpful as well.

@DavidAnderson684
Copy link

DavidAnderson684 commented Feb 18, 2022

@SamRemis The error is triggered here:

. PHP's error message doesn't imply the call was static. But you can see there you're definitely calling getResponse() on an Error object, but there's no such method on that object in the PHP manual.

@SamRemis
Copy link
Member

Right, I can see where that issue would happen. Maybe it was supposed to be getMessage or something, I'll look into the commit history and get a patch out. Do you have any info on what error was actually thrown?

@DavidAnderson684
Copy link

@SamRemis Unfortunately I have no more than the error message - it was sent to us by a user from their logs.

@SamRemis
Copy link
Member

SamRemis commented Feb 18, 2022

@DavidAnderson684,
Thanks for your help here! Will be nice to close out this issue. I just made a PR that should fix this once it's merged

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants