Azure / azure-rest-api-specs

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

[BUG] AzureActiveDirectory.CIAMResourceSKU has wrong x-ms-client-flatten on "tier" #30443

Open thomas11 opened 1 week ago

thomas11 commented 1 week ago

API Spec link

https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cpim/resource-manager/Microsoft.AzureActiveDirectory/preview/2023-05-17-preview/externalIdentities.json#L1506

API Spec version

2023-05-17-preview

Describe the bug

The properties of CIAMResourceSKU are defined as such:

      "properties": {
        "name": {
          "type": "string",
          "description": "The name of the SKU for the tenant.",
          "enum": [
            "Standard",
            "PremiumP1",
            "PremiumP2"
          ],
          "x-ms-enum": {
            "name": "CIAMResourceSKUName",
            "modelAsString": true
          }
        },
        "tier": {
          "type": "string",
          "description": "The tier of the tenant.",
          "enum": [
            "A0"
          ],
          "x-ms-mutability": [
            "create",
            "read"
          ],
          "x-ms-client-flatten": true,  // <--------
          "x-ms-enum": {
            "name": "CIAMResourceSKUTier",
            "modelAsString": true,
            "values": [
              {
                "value": "A0",
                "description": "The SKU tier used for all Azure AD for customers tenants."
              }
            ]
          }
        }

Note that tier is annotated with x-ms-client-flatten, while name is not. This annotation seems wrong because both properties are part of the SKU. The Azure portal JSON view also shows this:

    "sku": {
        "name": "Base",
        "tier": "A0"
    },

Expected behavior

Tools parsing the spec can correctly construct a SKU object for CIAMResource like

    "sku": {
        "name": "Base",
        "tier": "A0"
    },

Actual behavior

Tools parsing the spec construct a SKU object for CIAMResource with missing tier because it's flattened, like

    "sku": {
        "name": "Base",
    },

This leads to a 400 Bad Request response from Azure when creating a CIAMResource:

{"additionalInfo":null,"code":"InvalidProperties","details":null,"message":"The Tier field is required.","target":"createCIAMRequest.Sku.Tier"}

Reproduction Steps

To reproduce the Azure API error, run the create example with the tier property removed.

Reproducing the flattening depends on the tool used to parse the spec. For instance, Pulumi encounters this error in pulumi/pulumi-azure-native#3556.

Environment

No response

v-jiaodi commented 1 week ago

@AndresZourelli Please help take a look, thanks.

AndresZourelli commented 1 week ago

Yes seems like a bug. Ill update the spec and remove the "x-ms-client-flatten" property.

30461