Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Setting DefaultAzureCredentialOptions.TenantId twice leads to InvalidOperationException #47035

Closed
dfederm opened this issue Nov 8, 2024 · 1 comment · Fixed by #47037
Assignees
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@dfederm
Copy link

dfederm commented Nov 8, 2024

Library name and version

Azure.Identity 1.13.1

Describe the bug

I have code that essentially does:

DefaultAzureCredentialOptions defaultAzureCredentialOptions = new()
{
    TenantId = DefaultTenantId,
};

if (!string.IsNullOrEmpty(authSettings.TenantId))
{
    defaultAzureCredentialOptions.TenantId = authSettings.TenantId;
}

Which leads to the following error:

Applications should not set both TenantId and InteractiveBrowserTenantId. TenantId is preferred, and is functionally equivalent. InteractiveBrowserTenantId exists only to provide backwards compatibility.

I obviously can refactor the code to just set TenantId exactly once, but I shouldn't have to.

From looking at the code, setting TenantId also sets _interactiveBrowserTenantId.Value. Setting TenantId again throws due to this logic in the setter:

if (_interactiveBrowserTenantId.Updated && value != _interactiveBrowserTenantId.Value)
{
    throw new InvalidOperationException("Applications should not set both TenantId and InteractiveBrowserTenantId. TenantId is preferred, and is functionally equivalent. InteractiveBrowserTenantId exists only to provide backwards compatibility.");
}

Since _interactiveBrowserTenantId is set from the first setting of TenantId, but I did NOT set InteractiveBrowserTenantId directly, I consider this a bug.

Expected behavior

For it not to throw.

Actual behavior

Exception

Reproduction Steps

See above

Environment

No response

@github-actions github-actions bot added Azure.Identity Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team labels Nov 8, 2024
Copy link

github-actions bot commented Nov 8, 2024

Thank you for your feedback. Tagging and routing to the team member best able to assist.

@github-actions github-actions bot added the question The issue doesn't require a change to the product in order to be resolved. Most issues start as that label Nov 8, 2024
@christothes christothes removed the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Nov 8, 2024
@github-actions github-actions bot added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Nov 8, 2024
@github-project-automation github-project-automation bot moved this from Untriaged to Done in Azure Identity SDK Improvements Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
Development

Successfully merging a pull request may close this issue.

2 participants