SonarCloudPrepare@1 is adding an extra %27 to the API Url causing the task to fail with a 403

  • versions used SonarSource 1.26.1 via Azure Devops

I have noticed on AzureDevOps that the SonarCloudPrepare@1 task is adding an extra %27 into the API that is call by the task.

This is causing all of our build pipelines to fail at the same point.

When we click the link in the azure devops report we noticed that it has an extra %27 in the URL.

https://sonarcloud.io/api/settings/values?component=ourprojectkey' and we get the following error.

{

"errors": [

{
"msg": "Component key 'ourprojectkey'' not found"
}
]
}

If we remove the %27 from the URL it then returns the settings as expected.

{

"settings": [

{
"key": "sonar.project.monorepo.enabled",
"value": "false",
"inherited": true
},

{
"key": "sonaranalyzer-cs.nuget.packageVersion",

"value": "8.36.1.44192",
"inherited": true
},

{
"key": "sonaranalyzer.security.cs.pluginVersion",
"value": "9.4.0-M1.15235",
"inherited": true
},

{
"key": "sonar.cs.ignoreHeaderComments",
"value": "true",
"inherited": true
},
SonarScanner for MSBuild 5.5.3
Using the .NET Framework version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories...
10:40:47.823  Updating build integration targets...
10:40:48.318  Fetching analysis configuration settings...
10:40:48.415  10:40:48.415  WARNING: To analyze private projects make sure the scanner user has 'Browse' permission.
##[error]10:40:48.417  Failed to request and parse 'https://sonarcloud.io/api/settings/values?component=origo-services_Unipass': Response status code does not indicate success: 403 ().
10:40:48.417  Failed to request and parse 'https://sonarcloud.io/api/settings/values?component=ourprojectkey': Response status code does not indicate success: 403 ().

##[error]Unhandled Exception:
##[error]System.Net.Http.HttpRequestException: Response status code does not indicate success: 403 ().

We have made no changes and our task is pretty standard.

####################################################################
# SONARQUBE
####################################################################
- task: SonarCloudPrepare@1
  condition: and(succeeded(), eq(variables.RunSonarQube, 'true'))
  displayName: 'SonarQube Prepare'
  inputs:
    SonarCloud: 'SonarCloud'
    organization: 'our-organisation'
    scannerMode: 'MSBuild'
    projectKey: 'our-organisation_ourproject'
    projectName: 'Our Project'

Hi,

Welcome to the community!

Where do you see this link?

Because in your log snippet, you’re showing a 403 error which indicates a problem in the permissions for analysis. Did this problem start recently? And you mentioned that all your pipelines are failing. Do you mean across projects? Is it possible that your analysis user lost permissions or that the token you were using was revoked?

 
Ann

Had the same problem. error code is also 403. the extra %27 is appended by the azure UI. nothing to worry about.

I realized the service connection created in the Project is verified but the member who created this connection is removed from the sonarcloud org. so I created a new service connection and reflected the change in the pipeline prepare step and it works now.

1 Like