AssumeRoleCredentialProvider replaces non-RuntimeException failures with TypeError
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- aws, php
- Domain
- authentication, cloud
Research direction
The fault is in the rejection callback of AssumeRoleCredentialProvider::__invoke(), which type-hints RuntimeException. Run the reproduction script from the issue to see the TypeError. Done means Throwable is accepted, RuntimeException keeps its current handling, and other failures are rethrown unchanged with getPrevious() intact. Pull request #3372 already targets this, so check it before starting.
Written by the indexing model from the issue text.
Description
Describe the bug
When an STS request throws an exception that doesn’t extend RuntimeException, AssumeRoleCredentialProvider replaces it with a TypeError and loses the original exception.
Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
I think other exceptions should pass through unchanged instead of being replaced with a type error.
Current Behavior
The example below fails with:
Argument #1 ($exception) must be of type RuntimeException, Exception given
The original exception is also lost: getPrevious() returns null.
Reproduction Steps
This example reproduces it without making any network requests or needing an AWS account.
Install aws/aws-sdk-php version 3.399.2, then run:
<?php
require 'vendor/autoload.php';
$client = new Aws\Sts\StsClient([
'region' => 'us-east-1',
'version' => '2011-06-15',
'credentials' => ['key' => 'test', 'secret' => 'test'],
'http_handler' => function () {
throw new Exception('Request cancelled');
},
]);
$provider = new Aws\Credentials\AssumeRoleCredentialProvider([
'client' => $client,
'assume_role_params' => [
'RoleArn' => 'arn:aws:iam::123456789012:role/test',
'RoleSessionName' => 'test',
],
]);
$provider()->wait();
Possible Solution
The rejection callback in AssumeRoleCredentialProvider::__invoke() only accepts RuntimeException. It could accept Throwable, keep the existing handling for RuntimeException, and rethrow other failures unchanged.
Additional Information/Context
The same callback is still present on master.
SDK version used
3.399.2
Environment details (Version of PHP (php -v)? OS name and version, etc.)
PHP 8.4.25, Ubuntu 24.04.
Generated by Codex, and reviewed by @binaryfire.
- Dominant language
- PHP
- Stars
- 6.2k
- Forks
- 1.3k
- Avg merge
- 17h 23m
- Merged PRs (30d)
- 11
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from aws/aws-sdk-php
-
feature-request needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
aws/aws-sdk-php#3365 ·
Maintainers usually reply within 1 day
-
Event stream decoder reports a checksum mismatch when the checksum is read in partsPossibly taken @lazerg claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 25/100
aws/aws-sdk-php#3371 ·
Maintainers usually reply within 1 day
-
announcement
Difficulty 4/5 3-5 days Newbie friendliness 12/100
aws/aws-sdk-php#3369 ·
Maintainers usually reply within 1 day
-
bug needs-triage
Difficulty 4/5 3-5 days Newbie friendliness 30/100
aws/aws-sdk-php#3364 ·
Maintainers usually reply within 1 day
-
LambdaClient::invokeWithResponseStream fails because CURLOPT_TCP_KEEPALIVE is passed to Guzzle StreamHandlerPossibly taken @stobrien89 claimed this 36 days ago. Openbug needs-triage
aws/aws-sdk-php#3345 · 1 assignee ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
woocommerce/woocommerce-google-analytics-integration#699 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 60/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ProfessionalWiki/NeoWiki#1675 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100