We are seeing a strange issue with a SonarQube 10.3 Developer SKU (Docker image hosted in Azure) when doing analysis of a project that includes Azure Bicep files and the default AzureResourceManager rules
The Azure DevOps pipeline that runs the SonarQube is not failing, but within the SonarQube analysis step an error is 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 strange things are:
The SonarQube Analysis task is not failing - it reports success, but with the error in the log (which is OK as long as SonarQube tracks the issue)
So, I would expect an error/issue in the branch analysis in SonarQube, but none are seen.
The file the error is being reported on has not changed in over a year, so not even sure why it is being analyzed as a change?
As a workaround we are bypassing analysis of Bicep files
We found the problem, it is related to parsing Bicep files for App Insights Query packs.
If the Bicep resource for the query contains a body that starts with a comment
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, and moving the comment to the end of the body
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'
Thanks for the report and thanks for providing a reproducer! Glad that you found a workaround. I’ve created a ticket for the problem you reported, and you can track our progress on it here: https://sonarsource.atlassian.net/browse/SONARIAC-1383.