Azure / Azure/azure-rest-api-specs

[BUG] `batchAccount` - `storageAccountId` property cannot be removed through `update` method in go-azure-sdk

Open
#40,325 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Batch bug customer-reported Mgmt question Service Attention
Dominant language
TypeSpec
Stars
3.1k
Forks
6k
Avg merge
2d 21h
Merged PRs (30d)
432

Description

API Spec link

https://github.com/Azure/azure-rest-api-specs/blob/main/specification/batch/resource-manager/Microsoft.Batch/Batch/stable/2024-07-01/openapi.json?plain=1#L3590

API Spec version

2024-07-01

Describe the bug

The storageAccountId property of batchAccount resource is marked as required. When using patch method to update the batchAccount with auto-generated SDK such as go-azure-sdk, it is unable to remove storageAccountId as an empty string will be assigned to the property. This causes issue as that in https://github.com/hashicorp/terraform-provider-azurerm/pull/31615. To solve the issue, I guess the any of the following two solutions can be applied.

  1. Do not mark storageAccountId as required
  2. Define put method for batchAccount
Expected behavior

By using put method with Azure CLI az rest command, it is possible to remove existing storageAccountId with the following request body.

Request body

{
  "identity": {
    "type": "None",
    "userAssignedIdentities": null
  },
  "properties": {
    "autoStorage": {},
    "encryption": {
      "keySource": "Microsoft.Batch"
    }
  },
}
Actual behavior

When using go-azure-sdk update method generated from azure-rest-api-specs with terraform-provider-azurerm, even if storageAccountId is not specified, an empty string will be assigned as shown in the request body below due to the required behavior. This causes error as listed below.

Request body

{
  "identity": {
    "type": "None",
    "userAssignedIdentities": null
  },
  "properties": {
    "autoStorage": {
      "storageAccountId": ""
    },
    "encryption": {
      "keySource": "Microsoft.Batch"
    }
  },
}

Error

LinkedInvalidPropertyId: Property id '' at path 'properties.autoStorage.storageAccountId' is invalid. Expect fully qualified resource Id that start with '/subscriptions/{subscriptionId}' or '/providers/{resourceProviderNamespace}/'.
Reproduction Steps

The issue can be reproduced by using go-azure-sdk update method with the request body as mentioned in actual behavior section above.

Environment
  • uname -a
6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun  5 18:30:46 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
  • cat /etc/os-release
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.3 LTS
Release:        24.04
Codename:       noble
  • Azure CLI v2.77.0
  • Terraform v1.14.4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the 2024-07-01 Batch OpenAPI specification around the batchAccount autoStorage property, then compare the generated go-azure-sdk batchaccount/method_update.go and model_autostoragebaseproperties.go with the Terraform batch_account_resource.go usage. Reproduce the update request and determine which documented API-spec change makes removing storageAccountId work without sending an empty value.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, go, openapi, terraform
Domain
api, backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.