-
Notifications
You must be signed in to change notification settings - Fork 963
Description
Bug Report
Found this similar issue of parsing from azure side: ResourceSKUZoneDetails.UnmarshalJSON can't parse uppercase keys · Issue #23342 · Azure/azure-sdk-for-go
What happened?
The zoneDetails.Name field is completely missing from the JSON output when using the official Azure Go SDK v7.0.0, despite the Azure REST API returning this data correctly. This affects all Resource SKU queries that require zone-specific information.
Affected SDK Version:
- Package:
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7 - Version:
v7.0.0 - Go Version:
go version go1.23.4 darwin/arm64
What did you expect or want to happen?
The zoneDetails.Name field should be populated with the zone identifiers (e.g., ["1"], ["2"], ["3"]) as returned by the Azure REST API. This field is critical for applications that need to determine which specific availability zones support certain capabilities (like UltraSSD).
Expected structure (based on direct Azure REST API response):
{
"zoneDetails": [
{
"Name": ["2"], // Should contain specific zone identifiers
"capabilities": [
{
"name": "UltraSSDAvailable",
"value": "True"
}
]
}
]
}How can we reproduce it?
- Create a simple Go program using the SDK:
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"os"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
func main() {
subscriptionID := os.Getenv("AZURE_SUBSCRIPTION_ID")
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatal(err)
}
clientFactory, err := armcompute.NewClientFactory(subscriptionID, cred, nil)
if err != nil {
log.Fatal(err)
}
skuClient := clientFactory.NewResourceSKUsClient()
// Filter for VMs in a specific location with zones
filter := "location eq 'centralindia'"
pager := skuClient.NewListPager(&armcompute.ResourceSKUsClientListOptions{
Filter: &filter,
})
for pager.More() {
page, err := pager.NextPage(context.Background())
if err != nil {
log.Fatal(err)
}
for _, sku := range page.Value {
if sku.ResourceType != nil && *sku.ResourceType == "virtualMachines" {
if sku.LocationInfo != nil {
for _, locInfo := range sku.LocationInfo {
if locInfo.ZoneDetails != nil {
for _, zoneDetail := range locInfo.ZoneDetails {
// This field will be missing due to the bug
fmt.Printf("SKU: %s, ZoneDetails.Name: %v\n",
*sku.Name, zoneDetail.Name)
}
}
}
}
}
}
}
}- Run the program:
export AZURE_SUBSCRIPTION_ID="your-subscription-id"
go mod init test-app
go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7
go get github.com/Azure/azure-sdk-for-go/sdk/azidentity
go run main.go- Observe the bug:
- The
zoneDetail.Namefield will be completely missing from the JSON output - This occurs despite the zones being available in
locInfo.Zones - The bug affects all SKUs that have zone details
- The
Comparison with Direct REST API Call
Direct Azure REST API call (working correctly):
curl -H "Authorization: Bearer $TOKEN" \
"https://management.azure.com/subscriptions/$SUBSCRIPTION_ID/providers/Microsoft.Compute/skus?api-version=2021-07-01&\$filter=location eq 'centralindia'"Returns correct data:
{
"name": "Standard_NV16as_v4",
"locationInfo": [
{
"location": "CentralIndia",
"zones": ["1", "2", "3"],
"zoneDetails": [
{
"Name": ["2"], // POPULATED CORRECTLY
"capabilities": [{"name": "UltraSSDAvailable", "value": "True"}]
}
]
}
]
}SDK returns:
{
"name": "Standard_NV16as_v4",
"locationInfo": [
{
"location": "CentralIndia",
"zones": ["1", "2", "3"],
"zoneDetails": [
{
// "Name" FIELD COMPLETELY MISSING - SDK BUG
"capabilities": [{"name": "UltraSSDAvailable", "value": "True"}]
}
]
}
]
}Impact Analysis
Quantified Impact (tested with 47,762 VMs):
- VMs with zoneDetails present: 20,219
- VMs with zoneDetails.Name field present via SDK: 0
- VMs with zoneDetails.Name field present via REST API: 20,219
- Applications broken by this bug: Any requiring zone-specific capability information
Business Impact:
- Applications cannot determine which specific zones support capabilities like UltraSSD
- Impossible to make zone-aware resource provisioning decisions
- Forces developers to use direct REST API calls or abandon zone-specific logic
Anything we should know about your environment.
- Platform: macOS (darwin/arm64)
- Go Version: 1.23.4
- Authentication: Tested with Azure CLI, Service Principal, and Managed Identity
- Azure Regions Tested: Central India, East US, West US 2
- Resource Types Affected: All resource types with zone details (primarily Virtual Machines)
Root Cause Analysis
The issue appears to be in the JSON deserialization of the locationInfo.ZoneDetails.Name field. The field is correctly defined in the struct but is not being serialized into the JSON output, indicating the field is never populated from the REST API response.
Struct definition (appears correct):
type ResourceSKUZoneDetails struct {
Name []*string `json:"Name,omitempty"`
Capabilities []*ResourceSKUCapabilities `json:"capabilities,omitempty"`
}The deserialization logic seems to be missing or incorrectly handling the Name field from the Azure REST API response.