Skip to content

[BUG] No way to set IsChainedCredential when constructing ChainedTokenCredential with token sources #47140

Open
@dggsax

Description

@dggsax

Library name and version

Azure.Identity 1.10.4

Describe the bug

When using credential sources like AzurePowerShellCredential with a ChainedTokenCredential we are unable to leverage the exception handling logic of the Chained credential that allows it to work through the available credential sources, such as inside the AzurePowerShellCredential which throws a CredentialUnavailableException instead of whatever exception was thrown.

catch (Exception e)
{
throw scope.FailWrapAndThrow(e, isCredentialUnavailable: _isChainedCredential);
}
}
catch (Exception e)
{
throw scope.FailWrapAndThrow(e, isCredentialUnavailable: _isChainedCredential);
}

This is because the IsChainedCredential property on TokenCredentialOptions (which classes like AzurePowerShellCredentialOptions extend from) is internal (this property gets translated into the _isChainedCredential field on the credential sources which feed into the chained throwing logic)

/// <summary>
/// Gets or sets whether this credential is part of a chained credential.
/// </summary>
internal bool IsChainedCredential { get; set; }

Expected behavior

As a consumer of the ChainedTokenCredential we should be able to set that our credential sources are for chaining so that if one fails the others can be tried

Actual behavior

We are unable to set this variable by hand (what I am doing instead in the meantime is to use System.Reflection to set the _isChainedCredential field on my Token Sources, if they have the field, before I provide them to my ChainedTokenCredential instance)

Reproduction Steps

n/a

Environment

Runtime Environment:
OS Name: Mac OS X
OS Version: 14.7
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/8.0.300/

Metadata

Metadata

Assignees

Labels

Azure.IdentityClientThis issue points to a problem in the data-plane of the library.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

Status

Untriaged

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions