Strange Matches error (InnerTemplateStartLine and InnerTemplateStartLine) when linting a specific arm.
- Dominant language
- PowerShell
- Stars
- 468
- Forks
- 208
- PR merge metrics
- No merged PRs in 30d
Description
I'm running the ARM-TTK linter for a azuredeploy.json listed below and getting this strange error
json-file:
```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"privateDnsZones": {
"type": "Array"
},
"virtualNetwork": {
"type": "String"
},
"registrationEnabled": {
"type": "Bool",
"defaultValue": false
},
"location": {
"type": "String",
"defaultValue": "global"
}
},
"resources": [
{
"copy": {
"name": "privateDnsZones",
"count": "[length(parameters('privateDnsZones'))]"
},
"type": "Microsoft.Network/privateDnsZones",
"apiVersion": "2020-06-01",
"location": "[parameters('location')]",
"name": "[parameters('privateDnsZones')[copyIndex()]]",
"properties": {
},
"resources": [
{
"dependsOn": [
"[resourceId('Microsoft.Network/privateDnsZones', parameters('privateDnsZones')[copyIndex()])]"
],
"type": "SOA",
"apiVersion": "2020-06-01",
"name": "@",
"properties": {
"ttl": 3600,
"soaRecord": {
"email": "azureprivatedns-host.microsoft.com",
"expireTime": 2419200,
"host": "azureprivatedns.net",
"refreshTime": 3600,
"retryTime": 300,
"serialNumber": 1,
"minimumTtl": 300
}
}
},
{
"dependsOn": [
"[resourceId('Microsoft.Network/privateDnsZones', parameters('privateDnsZones')[copyIndex()])]"
],
"type": "virtualNetworkLinks",
"apiVersion": "2020-06-01",
"location": "[parameters('location')]",
"name": "dnsforwarder",
"properties": {
"registrationEnabled": "[parameters('registrationEnabled')]",
"virtualNetwork": {
"id": "[parameters('virtualNetwork')]"
}
}
}
]
}
]
}
```
Result form the ARM-TTK linter:
```powershell
2021-12-06 10:32:18 [INFO] File:[/tmp/lint/Policies/PrivateDNSZone/templates/azuredeploy.json]
MethodInvocationException: /usr/lib/microsoft/arm-ttk-master/arm-ttk/Test-AzTemplate.ps1:332
Line |
332 | $InnerTemplateStartLine =
| ~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "Matches" with "2" argument(s): "Start index
| cannot be less than 0 or greater than input length. (Parameter
| 'startat')"
MethodInvocationException: /usr/lib/microsoft/arm-ttk-master/arm-ttk/Test-AzTemplate.ps1:336
Line |
336 | $InnerTemplateEndLine =
| ~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "Matches" with "2" argument(s): "Start index
| cannot be less than 0 or greater than input length. (Parameter
| 'startat')"
2021-12-06 10:32:31 [ERROR] Found errors in [arm-ttk] linter!
2021-12-06 10:32:31 [ERROR] Error code: 1. Command output:
------
Validating templateszuredeploy.json
AllFiles
[+] JSONFiles Should Be Valid (260 ms)
deploymentTemplate
[+] adminUsername Should Not Be A Literal (28 ms)
[+] apiVersions Should Be Recent In Reference Functions (23 ms)
[+] apiVersions Should Be Recent (82 ms)
[+] artifacts parameter (17 ms)
[+] CommandToExecute Must Use ProtectedSettings For Secrets (23 ms)
[+] DependsOn Best Practices (18 ms)
[+] Deployment Resources Must Not Be Debug (90 ms)
[+] DeploymentTemplate Must Not Contain Hardcoded Uri (62 ms)
[+] DeploymentTemplate Schema Is Correct (8 ms)
[+] Dynamic Variable References Should Not Use Concat (5 ms)
[+] IDs Should Be Derived From ResourceIDs (76 ms)
[+] Location Should Not Be Hardcoded (48 ms)
[+] ManagedIdentityExtension must not be used (5 ms)
[+] Min And Max Value Are Numbers (7 ms)
[+] Outputs Must Not Contain Secrets (13 ms)
[+] Parameters Must Be Referenced (60 ms)
[+] Password params must be secure (9 ms)
[+] providers apiVersions Is Not Permitted (5 ms)
[+] ResourceIds should not contain (14 ms)
[+] Resources Should Have Location (10 ms)
[+] Resources Should Not Be Ambiguous (22 ms)
[+] Secure Params In Nested Deployments (34 ms)
[+] Secure String Parameters Cannot Have Default (4 ms)
[+] Template Should Not Contain Blanks (6 ms)
[+] Variables Must Be Referenced (5 ms)
[+] Virtual Machines Should Not Be Preview (39 ms)
[+] VM Images Should Use Latest Version (2 ms)
[+] VM Size Should Be A Parameter (20 ms)
```
Any ideas what this is? normally this file was linted normally but since yesterday we get this error. (file is not changed)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.