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

AwsS3S3Client::AwsS3{closure}(): Argument #1 ($e) must be of type AwsExceptionAwsException #2845

Closed
RaviJayagopal opened this issue Nov 29, 2023 · 4 comments
Assignees
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made. guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@RaviJayagopal
Copy link

Describe the bug

The following code is resulting in the error:
AwsS3S3Client::AwsS3{closure}(): Argument #1 ($e) must be of type AwsExceptionAwsException, TypeError given, called in /home/customer/www///vendor/guzzlehttp/promises/src/Promise.php on line 203

$s3Client = new Aws\S3\S3MultiRegionClient([
'version' => 'latest',
'region' => 'us-east-1',
'credentials' => [
'key' => $accessKey,
'secret' => $secretKey,
],
]);

$region = $s3Client->determineBucketRegion($bucketname);

The script crashes at the last line above at the determineBucketRegion call, and $region is null after the statement.

This works fine in PHP 7.x (tested up to v7.4.33), but crashes in all versions of PHP 8.x (tested up to v8.2.12).

AWS SDK:
"aws/aws-sdk-php": "3.x",
"guzzlehttp/guzzle": "7.8.",
"guzzlehttp/promises": "2.0.
",

TIA for your help.

Expected Behavior

$region should have a valid region value, and the code should not crash.

Current Behavior

Code crashes at:

$region = $s3Client->determineBucketRegion($bucketname);

Reproduction Steps

$s3Client = new Aws\S3\S3MultiRegionClient([
'version' => 'latest',
'region' => 'us-east-1',
'credentials' => [
'key' => $accessKey,
'secret' => $secretKey,
],
]);

$region = $s3Client->determineBucketRegion($bucketname);

Possible Solution

No response

Additional Information/Context

No response

SDK version used

3.x

Environment details (Version of PHP (php -v)? OS name and version, etc.)

PHP 8.x

@RaviJayagopal RaviJayagopal added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 29, 2023
@RaviJayagopal
Copy link
Author

The above issue still remains, but I found a workaround. So noting it here FWIW.

So instead of $s3Client->determineBucketRegion($bucketname), I used the following code to get the region, and I was able to get the region:

$result = $s3Client->getBucketLocation([
'Bucket' => $bucketname,
]);

$region = $result['LocationConstraint'];

@yenfryherrerafeliz yenfryherrerafeliz self-assigned this Nov 29, 2023
@yenfryherrerafeliz
Copy link
Contributor

Hi @RaviJayagopal, can you please confirm the SDK version that you are using? since you probably would need to update. You can verify this by running: composer show aws/aws-sdk-php | grep "versions :". I just did a test using the version 3.291.0 and I did not have any issues.

My code:

<?php
require '../vendor/autoload.php';

use Aws\S3\S3Client;

$client = new S3Client(['region' => getenv('TEST_REGION')]);
$response = $client->determineBucketRegion(getenv('TEST_BUCKET'));

print_r([$response]);

Response I got:

Array
(
    [0] => us-east-2
)

My PHP version:

USER@3c0630413e17 issue-2845 % php -v
PHP 8.3.0 (cli) (built: Nov 24 2023 13:21:02) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.0, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.0, Copyright (c), by Zend Technologies

Please let me know.

Thanks!

@yenfryherrerafeliz yenfryherrerafeliz added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Nov 29, 2023
@stobrien89 stobrien89 added guidance Question that needs advice or information. and removed bug This issue is a bug. labels Dec 1, 2023
Copy link

github-actions bot commented Dec 5, 2023

This issue has not recieved a response in 1 week. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Dec 5, 2023
Copy link

github-actions bot commented Dec 5, 2023

⚠️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
closing-soon This issue will automatically close in 4 days unless further comments are made. guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

3 participants