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] ArmClient.GetDenyAssignments(identifier) fails when the identifier is in a resource level #40050

Closed
galhag opened this issue Nov 16, 2023 · 2 comments
Assignees
Labels
ARM bug This issue requires a change to an existing behavior in the product in order to be resolved. Mgmt This issue is related to a management-plane library. 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

@galhag
Copy link

galhag commented Nov 16, 2023

Library name and version

Azure.ResourceManager.Authorization 1.0.1

Describe the bug

When fetching a resource deny assignments using the ArmClient
It fails with: System.ArgumentException
essage=Value cannot be empty or contain only white-space characters. (Parameter 'resourceType')
Source=Azure.Core
StackTrace:
at Azure.Core.Argument.AssertNotNullOrWhiteSpace(String value, String name)
at Azure.Core.ResourceType..ctor(String resourceType)
at Azure.Core.ResourceType.op_Implicit(String resourceType)
at Azure.ResourceManager.Authorization.DenyAssignmentCollection.GetAllAsync(String filter, CancellationToken cancellationToken)
at Azure.ResourceManager.Authorization.DenyAssignmentCollection.System.Collections.Generic.IAsyncEnumerable<Azure.ResourceManager.Authorization.DenyAssignmentResource>.GetAsyncEnumerator(CancellationToken cancellationToken)

The issue is in the DenyAssignmentCollection, when it checks else if (Id.ResourceType == "")
There is implicit convertion from string to ResourceType, and the resource type ctor does not allow empty strings.

you can fix it by changing it to do explicit string else if (Id.ResourceType.ToString() == "")

Expected behavior

Should return the role assignments of the given resource

Actual behavior

fails with System.ArgumentException

Reproduction Steps

var armClient = new ArmClient(new AzureCliCredential());
var resource =
ResourceIdentifier.Parse(
"/subscriptions/{subId}/resourceGroups/{resourceGroup}/providers/{RP}/{Type}/{Name}");
var denyAssignments = await armClient.GetDenyAssignments(resource).ToListAsync();

Environment

.NET SDK:
Version: 7.0.404
Commit: 22f221a24c

Runtime Environment:
OS Name: Windows
OS Version: 10.0.22621
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.404\

Host:
Version: 7.0.14
Architecture: x64
Commit: 808851b07a

@github-actions github-actions bot added ARM customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. needs-team-triage Workflow: This issue needs the team to triage. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Nov 16, 2023
@jsquire jsquire added needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team and removed needs-team-triage Workflow: This issue needs the team to triage. labels Nov 16, 2023
@jsquire
Copy link
Member

jsquire commented Nov 16, 2023

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

@HarveyLink HarveyLink added this to the 2024-02 milestone Jan 10, 2024
@jsquire jsquire removed this from the 2024-02 milestone Feb 26, 2024
@ArthurMa1978 ArthurMa1978 added bug This issue requires a change to an existing behavior in the product in order to be resolved. and removed customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Mar 12, 2024
@HarveyLink
Copy link
Member

Issue fixed, will ship in the next release.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ARM bug This issue requires a change to an existing behavior in the product in order to be resolved. Mgmt This issue is related to a management-plane library. 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
None yet
Development

No branches or pull requests

4 participants