The Issue
We saw an issue with our SonarQube 10.3 Developer Edition (that is running as a Docker image hosted in Azure) when it was doing the analysis of a project that included Azure Bicep files.
The Azure DevOps pipeline that triggered the SonarQube analysis was not failing, but within the SonarQube analysis step an error was reported in the task log
INFO: Sensor IaC AzureResourceManager Sensor is restricted to changed files only
INFO: 1 source file to be analyzed
##[error]ERROR: Cannot parse 'AzureServices/QueryPack.bicep:89:1'
The Solution
Turns out the problem was related to parsing Bicep files for App Insights Query packs.
If the Bicep resource for the query contains a body
property that starts with a comment e.g.
resource querypacks_DefaultQueryPack 'microsoft.operationalInsights/querypacks/queries@2019-09-01-preview' = {
parent: QueryPack
name: ...
properties: {
displayName: ...
description: ..
body: '// 35 is ABC\r\n// 40 is XYZ \r\nrequests\r\n| where name has "myfacade.svc"\r\n| order by timestamp desc\r\n| where name !has "GET"\r\n| summarize count() by name, resultCode\r\n| render columnchart'
We get the error ##[error]ERROR: Cannot parse 'AzureServices/QueryPack.bicep:89:1
We can fix this by not starting the body
with a comment, just moving the comment to the end of the body
i.e.
resource querypacks_DefaultQueryPack 'microsoft.operationalInsights/querypacks/queries@2019-09-01-preview' = {
parent: QueryPack
name: ...
properties: {
displayName: ...
description: ..
body: 'requests\r\n| where name has "myfacade.svc"\r\n| order by timestamp desc\r\n| where name !has "GET"\r\n| summarize count() by name, resultCode\r\n| render columnchart\r\n// 35 is ABC\r\n// 40 is XYZ'