Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

AssumeRoleCredentialProvider replaces non-RuntimeException failures with TypeError

未关闭
#3,370 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@lazerg 已经在做这个了。

开始于 2026年10月10日。

  • #3372 来自 @lazerg —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
aws, php

调研方向

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 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

aws/aws-sdk-php 的其他 Issue

查看 aws/aws-sdk-php 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。