Skip to content

azure.ResourceGroupExistsE returns an error if the resource group doesn't exist, rather than false #1537

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

Open
djpnicholls opened this issue Apr 9, 2025 · 0 comments
Assignees

Comments

@djpnicholls
Copy link

In this function, there's a special check on the error returned by GetResourceGroupE:

if err != nil {
if ResourceNotFoundErrorExists(err) {
return false, nil
}
return false, err

This is intended to return false if the resource group doesn't exist, since that's what ResourceGroupExistsE is checking.

However, in fact, it returns an error:

Error:      	Received unexpected error:
            	            	resources.GroupsClient#Get: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="ResourceGroupNotFound" Message="Resource group 'TerraTest-C9kIU3' could not be found."

The issue is that the function ResourceNotFoundErrorExists is checking for an error with the code ResourceNotFound:

return (requestError.ServiceError.Code == "ResourceNotFound")

But when checking for the existence of a resource group that doesn't exist, azure returns an error with the code ResourceGroupNotFound (as you can see in the error).

I suspect there needs to be a separate ResourceGroupNotFoundErrorExists function that can be called by ResourceGroupExistsE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants