Parse error in Bicep file

Must-share information (formatted with Markdown):

  • which versions are you using SonarScanner 4.8.1.3023
  • how is SonarQube deployed: Azure devops pipeline
  • what are you trying to achieve Scan a bicep file
  • what have you tried so far to achieve this SonarScanner gives error but runs successful

I have changed a bicep file to make use of the single line object declaration but the scanner gives an error on this:

ERROR: Cannot parse 'Infrastructure.bicep:18:1'

This is line 17 and 18:

var toConnect = concat([
  { name: 'web', network: cidrSubnet(networkAddress, 24, subnets.WebServers) }

Even though I get an error, the scanner continues and reports a success. Because of this, the pipeline doesn’t stop but continues. The SonarQube site doesn’t show a warning or notification that there was an issue in the latest scan.

Hey there.

What version of SonarQube are you using? This should be found in the footer of your SonarQube instance.

Hello Colin,

We are using the Developer Edition, Version 10.3 (build 82913)

Thanks! Can you provide a full, valid Bicep file that reproduces the issue?

Hello Colin,

Sorry for the late reply, here is a minimal bicep file that fails:

var toConnect = concat([
  { name: 'web', network: '127.0.0.1' }
], [
  { name: 'prod', network: '10.0.0.1' }
])

The error is the following:
ERROR Cannot parse 'ComBusOnlineAzure/Infrastructure/db/nsg.bicep:2:1

Placing all of this code on a single line still gives an error (now reporting “nsg.bicep:1:1”).
Copmpiling this script to ARM with following code generates a valid ARM json file and a warning that the variable ‘toConnect’ is not used.

az bicep build --file nsg.bicep

We are using the following:

  • Developer Edition v10.6 (92116)
  • SonarScanner CLI 6.1.0.4477

Hello @supervo,

Thanks for raising awareness about this issue.

I investigated and found an issue in the Bicep parser. To follow up on this, I have created a ticket.
We expect to work on the Bicep parser soon, and we will make sure to take care of this.

Thank you again for your help and sorry for the inconvenience caused.

Best regards,
Rudy

Hello @rudy.regazzoni,

We have just updated to Developer Edition v10.7 (96327) and this issue is no longer present.

Thank you for looking into this.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.