AssumeRoleCredentialProvider replaces non-RuntimeException failures with TypeError
维护者通常 2 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- aws, php
- 领域
- authentication, cloud
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- PHP
- 星标
- 6.2k
- 派生
- 1.3k
- 平均合并
- 2 天 7 小时
- 30 天内合并 PR
- 11
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
aws/aws-sdk-php 的其他 Issue
-
feature-request needs-triage
难度 2/5 1-3 小时 新手友好度 72/100
aws/aws-sdk-php#3365 ·
维护者通常 2 天内回复
-
Event stream decoder drops the final event when reading it reaches EOF可能已有人在做 @lazerg 于 1 天前认领。 未关闭
难度 3/5 半天 新手友好度 62/100
aws/aws-sdk-php#3374 ·
维护者通常 2 天内回复
-
Event stream decoder reports a checksum mismatch when the checksum is read in parts可能已有人在做 @lazerg 于 5 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 25/100
aws/aws-sdk-php#3371 ·
维护者通常 2 天内回复
-
announcement
难度 4/5 3-5 天 新手友好度 12/100
aws/aws-sdk-php#3369 ·
维护者通常 2 天内回复
-
bug needs-triage
难度 4/5 3-5 天 新手友好度 30/100
aws/aws-sdk-php#3364 ·
维护者通常 2 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 66/100
Automattic/blocks-engine#2866 ·
维护者通常 1 天内回复
-
enhancement good first issue help wanted
难度 2/5 1-3 小时 新手友好度 82/100
-
backend gamification P0
难度 2/5 1-3 小时 新手友好度 66/100
semanadeinformatica/website#461 ·
-
HttpRequestTrait fatals on WordPress 7.2: $blocked_http_requests clashes with WP_UnitTestCase_Base未关闭
难度 2/5 1-3 小时 新手友好度 72/100
-
area: docs eco: php good first issue help wanted lane: free-agent roadmap size: XS type: docs
难度 2/5 1-3 小时 新手友好度 68/100
arminazimi/evergreen#453 ·
维护者通常 1 天内回复