Azure / azure-rest-api-specs

The source for REST API specifications for Microsoft Azure.
MIT License
2.61k stars 5.01k forks source link

[BUG] Cognitive Services Account "kind" not annotated as immutable #27777

Open thomas11 opened 7 months ago

thomas11 commented 7 months ago

API Spec link

https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2023-10-01-preview/cognitiveservices.json#L3125

API Spec version

2023-10-01-preview

Describe the bug

The kind of a Cognitive Services Account (one of az cognitiveservices account list-kinds) cannot be changed after the account is created. However, the property is not marked up as immutable, e.g., via

          "x-ms-mutability": [
            "read",
            "create"
          ],

As a result, programs and tools generated from the spec, like Pulumi, misleadingly let the user change the account kind which then fails at runtime.

Expected behavior

From the spec, a user or a tool parsing the spec should understand that kind cannot be changed. Pulumi, for instance, could report a suitable error to the user before even trying to make an Azure request.

Actual behavior

Users and tools are unaware of the immutability of kind and attempt to change it which fails at run time.

Reproduction Steps

Create an account with this payload (from the spec, CreateAccountMin.json):

{
    "api-version": "2023-10-01-preview",
    "subscriptionId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "resourceGroupName": "myResourceGroup",
    "accountName": "testCreate1",
    "account": {
      "location": "West US",
      "kind": "CognitiveServices",
      "sku": {
        "name": "S0"
      },
      "properties": {},
      "identity": {
        "type": "SystemAssigned"
      }
    }
  }

Then, attempt to update it with a changed kind, which will fail. That is correct, but it means the kind property should be annotated as immutable.

Environment

No response

zzhxiaofeng commented 6 months ago

@tianxinliu Please help have a look, thank you.