Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arm-ttk is not validating UI output type with Template input or parameter type #444

Closed
KRKandavel opened this issue Jul 2, 2021 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@KRKandavel
Copy link

Here is the snippet of the Template parameter: (Integer)
"appRootDiskSize": {
"type": "int",
"minValue": 30,
"maxValue": 2048,
"defaultValue": 30,
"metadata": {
"description": "Please select the size of the data disk you wish to deploy (value is integer GB)."
}
},

Here is the snippet of UI element and output: (String type)
"bladeTitle": "app Configuration",
"elements": [
{
"name": "deployApp",
"type": "Microsoft.Common.OptionsGroup",
"label": "Deploy App",
"defaultValue": "true",
"toolTip": "Optionally select to deploy App",
"constraints": {
"allowedValues": [
{
"label": "true",
"value": "yes"
},
{
"label": "false",
"value": "no"
}
],
"required": true
}
},
{
"name": "rootDiskSize",
"type": "Microsoft.Common.TextBox",
"label": "Swarm instance root disk size",
"defaultValue": "30",
"toolTip": "Provide the size of the Swarm root disk - The size (GB) of the Managed disk.",
"constraints": {
"required": true,
"regex": "^([3-9]\d{1}\d*|\d{3}\d*)$",
"validationMessage": "Value must be numeric and greater than or equal to 30"
},
"visible": true
},
],
"visible": "[equals(steps('SwarmConfig').deployApp, 'yes')]"
}
]
},

UI output:
"swarmRootDiskSize": "[steps('SwarmConfig').vmSettings.rootDiskSize]",

  • Once you have the createUIDefinition.json & mainTemplate.json files are ready based on the above data, you can do the UI input validation using "arm-ttk" toolkit, and "Deploy To Azure" URL and Marketplace.
  • You can notice both "arm-ttk" and "Deploy To Azure" pass validation and there is no type mismatch - template expects integer whereas integer is passed from UI output.
  • If you upload the same template to Marketplace then you can notice the JToken validation error, whereas this is not exposed or caught in both arm-ttk or "deploy to azure" URL methods.
    Resolution: Resolved by modifying the UI output as below:
    "swarmRootDiskSize": "[int(coalesce(steps('SwarmConfig').vmSettings.rootDiskSize, 30))]",

ASK: Implement in arm-ttk toolkit to validate if the output type matches the template input parameter type. This helps catching the type mismatch errors in arm-ttk tool instead of noticing it only after publishing it to marketplace.

@ghost ghost added the Needs: triage 🔍 label Jul 2, 2021
@bmoore-msft
Copy link
Contributor

Good catch... we'll add to the list...

@bmoore-msft bmoore-msft added enhancement New feature or request and removed Needs: triage 🔍 labels Jul 12, 2021
@bmoore-msft bmoore-msft added this to the M4 milestone Sep 10, 2021
StartAutomating added a commit to StartAutomating/arm-ttk that referenced this issue Feb 4, 2022
bmoore-msft pushed a commit that referenced this issue Mar 1, 2022
* Fixing #444:  Template Output Data Types

* Adding positive/negative tests

* Expanding list of acceptable data type coercion functions

* Adding Length to -AllowedFunctionInOutput

* Adding boolean case to failure

* Adding Tracing for CI/CD debugging

* More tracing for debugging CI/CD

* Adding -Debug support to test functions

* Adding -Debug to the Outputs-Must-Be-Present-In-Template-Parameters

* Updating failure case (making JSON more correct)

* Fixing casing in createUiDefinition filename

* Cleaning up CI/CD debugging

* Outputs-Must-Be-Present-In-Template-Parameters:  Switching to warning.  Adding notes.

* Outputs-Must-Be-Present-In-Template-Parameters:  Switching to warning.  Adding notes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants