Azure / arm-ttk

Azure Resource Manager Template Toolkit
https://aka.ms/arm-ttk
MIT License
441 stars 188 forks source link

arm-ttk applies "CreateUIDefinition Must Not Have Blanks" test to user data #772

Open raouche opened 7 months ago

raouche commented 7 months ago

arm-ttk version: 0.24 Scenario: You have a DropDown control where the value of each "allowedValue" constraint is a JSON object that is domain-specific (see the sample CUID below that applies to the birds domain). Note that the JSON payload is user data, not CUID properties.

Problem: When running arm-ttk against this example, the following error is returned, indicating that arm-ttk is applying the "CreateUIDefinition Must Not Have Blanks" test case not only to CUID base constructs but also to user data:

CreateUIDefinition Must Not Have Blanks
  - Error: Empty property: synonyms found on line: 15

NOTE: While one can argue that perhaps the JSON payloads of the user data should remove the empty properties, there are many cases, especially with generated data, where removing the empty property is not an option and adds a certain maintenance overhead.

Sample CUID:

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [
      {
        "constraints": {
          "allowedValues": [
            {
              "label": "Pelican",
              "value": {
                "family": "Palecanidae",
                "genus": "Pelecanus",
                "synonyms": ""
              }
            },
            {
              "label": "Heron",
              "value": {
                "family": "Ardeidae",
                "genus": "Ardea",
                "synonyms": "Cochlearidae"
              }
            }
          ]
        },
        "label": "DropDown1",
        "name": "DropDown1",
        "toolTip": "DropDown1",
        "type": "Microsoft.Common.DropDown"
      }
    ],
    "steps": [],
    "outputs": {
      "location": "[location()]",
      "DropDown1": "[basics('DropDown1')]"
    }
  },
  "metadata": {
    "_generator": {
      "name": "MaestroStudio",
      "sku": "Solo",
      "version": "0.9.0.0",
      "template": {
        "author": "StratusOn",
        "id": "EA622966-CE0C-46E7-841B-73C2E6ED5DEB",
        "description": "A blank Azure Marketplace Managed Application offer."
      }
    },
    "_sync": {
      "offer": {
        "displayName": "My Offer"
      },
      "plan": {
        "displayName": "Plan"
      }
    }
  }
}