SonarCloudAnalyze 1.40.0 broke JSON deserialization for SONARQUBE_SCANNER_PARAMS

Template for a good new topic, formatted with Markdown:

  • ALM used: Azure DevOps
  • CI system used: Azure DevOps
  • Scanner command used: - task: SonarCloudAnalyze@1
  • Languages of the repository: C#
  • Error observed:
##[debug]Processed: ##vso[task.logissue type=error;]ERROR: Error during SonarScanner execution
ERROR: Error during SonarScanner execution
##[error]java.lang.IllegalStateException: Failed to parse JSON in SONARQUBE_SCANNER_PARAMS environment variable
##[debug]Processed: ##vso[task.logissue type=error;]java.lang.IllegalStateException: Failed to parse JSON in SONARQUBE_SCANNER_PARAMS environment variable
java.lang.IllegalStateException: Failed to parse JSON in SONARQUBE_SCANNER_PARAMS environment variable
##[error]at org.sonarsource.scanner.api.Utils.loadEnvironmentProperties(Utils.java:65)
##[debug]Processed: ##vso[task.logissue type=error;]at org.sonarsource.scanner.api.Utils.loadEnvironmentProperties(Utils.java:65)
	at org.sonarsource.scanner.api.Utils.loadEnvironmentProperties(Utils.java:65)
##[error]at org.sonarsource.scanner.cli.Conf.loadEnvironmentProperties(Conf.java:78)
##[debug]Processed: ##vso[task.logissue type=error;]at org.sonarsource.scanner.cli.Conf.loadEnvironmentProperties(Conf.java:78)
	at org.sonarsource.scanner.cli.Conf.loadEnvironmentProperties(Conf.java:78)
##[error]at org.sonarsource.scanner.cli.Conf.loadGlobalProperties(Conf.java:85)
	at org.sonarsource.scanner.cli.Conf.properties(Conf.java:59)
##[debug]Processed: ##vso[task.logissue type=error;]at org.sonarsource.scanner.cli.Conf.loadGlobalProperties(Conf.java:85)
	at org.sonarsource.scanner.cli.Conf.properties(Conf.java:59)
	at org.sonarsource.scanner.cli.Conf.loadGlobalProperties(Conf.java:85)
	at org.sonarsource.scanner.cli.Conf.properties(Conf.java:59)
##[error]at org.sonarsource.scanner.cli.Main.execute(Main.java:70)
##[debug]Processed: ##vso[task.logissue type=error;]at org.sonarsource.scanner.cli.Main.execute(Main.java:70)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:70)
##[error]at org.sonarsource.scanner.cli.Main.main(Main.java:62)
##[debug]Processed: ##vso[task.logissue type=error;]at org.sonarsource.scanner.cli.Main.main(Main.java:62)
	at org.sonarsource.scanner.cli.Main.main(Main.java:62)
##[error]Caused by: java.lang.UnsupportedOperationException: Not an object: "{\"sonar.host.url\":\"https://sonarcloud.io/\",\"sonar.login\":***,\"sonar.organization\":\"REDACTED\",\"sonar.projectKey\":\"REDACTED\",\"sonar.projectName\":\"REDACTED\",\"sonar.projectVersion\":\"1.0\",\"sonar.scanner.metadataFilePath\":\"D:\\\\a\\\\_temp\\\\sonar\\\\43897\\\\4736c3d1-0f5d-f3ef-7be4-10813b7b3f25\\\\report-task.txt\",\"sonar.exclusions\":\"REDACTED\"}"
  • Steps to reproduce: Run a build with SonarCloudAnalyze 1.40.0
  • Potential workaround: Pinning SonarCloudAnalyze to 1.38.0

I noticed the above failure start in our builds between 6/12-6/14. After some troubleshooting, I noticed that the SONARQUBE_SCANNER_PARAMS json being encoded. I suspected based on the error message, this is the issue. I also noticed I was missing enclosing quotes around sonar.exclusions and sonar.inclusions, but I added and that did not fix it either.

Update: I pinned SonarCloudAnalyze to 1.38.0 and it started working again, something in 1.40.0 must have broken it.

1.38.0
##[debug]SONARQUBE_SCANNER_PARAMS={“sonar.host.url”:“https://sonarcloud.io/",“sonar.organization”:“REDACTED”,“sonar.projectKey”:“REDACTED”,“sonar.projectName”:“REDACTED”,“sonar.projectVersion”:“1.0”,“sonar.scanner.metadataFilePath”:“D:\\a\\_temp\\sonar\\20230608.1\\7890e466-78ba-cb66-3d73-449cf3ec3fb4\\report-task.txt”,“sonar.exclusions”:"REDACTED sonar.inclusions=REDACTED”}

1.40.0
##[debug]SONARQUBE_SCANNER_PARAMS=“{"sonar.host.url":"https://sonarcloud.io/\",\“sonar.login\”:***,\“sonar.organization\”:\“REDACTED\”,\“sonar.projectKey\”:\“REDACTED\”,\“sonar.projectName\”:\“REDACTED\”,\“sonar.projectVersion\”:\“1.0\”,\“sonar.scanner.metadataFilePath\”:\“D:\\\\a\\\\_temp\\\\sonar\\\\43897\\\\4736c3d1-0f5d-f3ef-7be4-10813b7b3f25\\\\report-task.txt\”,\“sonar.exclusions\”:\"REDACTED sonar.inclusions=REDACTED”}"

Can anyone from Sonar team respond to this?

Thanks,
Devin

bumping so someone from Sonar team can respond.

Thanks,
Devin

Hi @dglambert,

Thank you for your report. I would need more information in order to reproduce this behavior, could you share your:

  • yaml file for the pipeline (please hide any sensitive information)
  • logs from SonarCloudPrepare task

Hi @Stan there, I can provide what you need we are from same team

@Stan ^^ are you still checking this issue ?