jq: error: null (null) has no keys for any template without a parameters object
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 90/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- powershell
- Domain
- ci-cd
Research direction
Start in src/functions/Invoke-AzOpsPush.ps1 around line 396 and inspect the jq statement applied to .parameters. Reproduce it with a parameterless ARM or Bicep template, then verify that validation or push no longer logs the null-keys error while still handling templates with parameters.
Written by the indexing model from the issue text.
Description
Describe the bug
Given a parameterless resource template, when attempting to push or validate the template using the AzOps pipelines, the jq statement throws an error statement in the pipeline log.
jq: error (at <stdin>:76): null (null) has no keys
This is not super critical, as the Powershell ConvertFrom-Json -AsHashtable seems to handle the error case just fine, however the error log could be interpreted as an actual fault.
Scripts in question:
Steps to reproduce
- A parameterless main.bicep:
var location = 'westeurope'
resource example 'Microsoft.Storage/storageAccounts@2023-05-01' = {
name: 'st${uniqueString(resourceGroup().id)}'
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
}
- Build it and show Bicep omits parameters entirely rather than emitting {}:
$ bicep build main.bicep --outfile main.json
$ jq 'has("parameters")' main.json
false
$ jq '.parameters | with_entries(select(.value.defaultValue == null))' main.json
jq: error: null (null) has no keys
Note:
The is not a bicep specific error, and is even reproducible with the following bare-bones ARM template:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": []
}
Proposed Solution:
Add a safeguard to the jq statement, which defaults to an empty object in case .parameters does not exist:
Old: .parameters | with_entries(select(.value.defaultValue == null))
New: .parameters // {} | with_entries(select(.value.defaultValue == null))
- Dominant language
- PowerShell
- Stars
- 420
- Forks
- 174
- Avg merge
- 16d 18h
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Azure/AzOps
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 3/5 1-2 days Newbie friendliness 78/100
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
-
Difficulty 4/5 3-5 days Newbie friendliness 28/100
-
triage
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sympozium-ai/sympozium#627 ·
-
repo:raw-data
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
hotosm/raw-data-api#316 · 1 comment ·
-
agentic-workflows cascade-suspected
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
willow
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
openedx/openedx-authz#460 ·