Skip to content

AssumeRoleCredentialProvider replaces non-RuntimeException failures with TypeError #3370

Open

Description

@binaryfire

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.

Activity

  1. self-assigned this
    on Oct 16, 2026
  2. added
    bugThis issue is a bug.
    investigatingThis issue is being investigated and/or work is in progress to resolve the issue.
    and removed
    investigatingThis issue is being investigated and/or work is in progress to resolve the issue.
    on Oct 16, 2026
  3. stobrien89 commented on Oct 16, 2026

    @stobrien89
    Member

    Thanks for reporting this @binaryfire- mentioned this in the PR, but we'll wait to merge the fix until after today's release.

  4. added
    pending-releaseThis issue will be fixed by an approved PR that hasn't been released yet.
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.pending-releaseThis issue will be fixed by an approved PR that hasn't been released yet.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions