From c84f72d9072f38ce03516515f1c4d2a97f1ae422 Mon Sep 17 00:00:00 2001 From: katherinelc321 Date: Thu, 16 May 2024 13:20:56 -0400 Subject: [PATCH] fix error code --- frontend/middleware_validatestatic.go | 4 ++-- internal/api/arm/error.go | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/middleware_validatestatic.go b/frontend/middleware_validatestatic.go index 130c67092..a50bd8594 100644 --- a/frontend/middleware_validatestatic.go +++ b/frontend/middleware_validatestatic.go @@ -32,14 +32,14 @@ func MiddlewareValidateStatic(w http.ResponseWriter, r *http.Request, next http. if resourceGroupName != "" { if !rxResourceGroupName.MatchString(resourceGroupName) { - arm.WriteError(w, http.StatusBadRequest, arm.CloudErrorCodeResourceGroupNotFound, "", "Resource group '%s' is invalid.", resourceGroupName) + arm.WriteError(w, http.StatusBadRequest, arm.CloudErrorInvalidResourceGroupName, "", "Resource group '%s' is invalid.", resourceGroupName) return } } if resourceName != "" { if !rxResourceName.MatchString(resourceName) { - arm.WriteError(w, http.StatusBadRequest, arm.CloudErrorCodeResourceNotFound, "", "The Resource '%s/%s' under resource group '%s' is invalid.", api.ResourceType, resourceName, resourceGroupName) + arm.WriteError(w, http.StatusBadRequest, arm.CloudErrorInvalidResourceName, "", "The Resource '%s/%s' under resource group '%s' is invalid.", api.ResourceType, resourceName, resourceGroupName) return } } diff --git a/internal/api/arm/error.go b/internal/api/arm/error.go index c17917400..04bb78157 100644 --- a/internal/api/arm/error.go +++ b/internal/api/arm/error.go @@ -23,6 +23,8 @@ const ( CloudErrorCodeResourceNotFound = "ResourceNotFound" CloudErrorCodeResourceGroupNotFound = "ResourceGroupNotFound" CloudErrorCodeInvalidSubscriptionID = "InvalidSubscriptionID" + CloudErrorInvalidResourceName = "InvalidResourceName" + CloudErrorInvalidResourceGroupName = "InvalidResourceGroupName" ) // CloudError represents a complete resource provider error.