ERROR: Failed to prepare write of the sensor cache

The analysis does end up going through but got the error about the write of the sensor cache. You can see the error message below. We didn’t have any recent changes yet but in the log, it’s showing “Sensor cache enabled” which we didn’t see in the last success time.

INFO: ANALYSIS SUCCESSFUL, you can find the results at: https://sonarcloud.io/dashboard?id=test_main
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at https://sonarcloud.io/api/ce/task?id=AYWlTzOg4thDE8pGa9Ex123
DEBUG: GET 403 https://ea6ne4j2sb.execute-api.eu-central-1.amazonaws.com/current/v1/sensor_cache/prepare_write?organization=test&project=test_main | time=346ms
ERROR: Failed to prepare write of the sensor cache
ERROR: Failed to prepare write of the sensor cache
[error]org.sonar.api.utils.MessageException: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator
org.sonar.api.utils.MessageException: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator

Hi @cnguyenbg

Welcome to the community!
I’ll investigate that issue.
Could you please tell me which CI system you are using, and share the configuration of the Sonar scanner (command line / workflow file / build file)?

Thanks in advance,
Claire

Hi Claire,

We’re using the Azure Devops Pipeline. We’re using tasks Prepare Analysis Configuration, Run Code Analysis and Publish Quality Gate Result that are provided by Sonar in the pipeline. There is nothing special in the configuration. You can see the configuration of the Sonar scanner below.

steps:
- task: SonarSource.sonarcloud.1....SonarCloudPrepare@1
  displayName: 'Prepare SonarCloud'
  inputs:
    SonarCloud: 'Sonar Content Test'
    organization: Test
    projectKey: 'test_main'
    projectName: main
     extraProperties: |
        sonar.verbose=true

For scan:

steps:

- task: SonarSource.sonarcloud.1...

  displayName: 'Run Code Analysis'

We’re also encountering this issue all of a sudden, with no changes to our pipelines. We too are using Azure Pipelines.

The Prepare Analysis Configuration step completes without issue, and the Run Code Analysis (v1.34.0) step runs too, but it shows an error and has also caused some pipelines to hang for hours!

19:58:07.710 INFO: Load sensor cache
19:58:08.078 DEBUG: GET 403 https://ea6ne4j2sb.execute-api.eu-central-1.amazonaws.com/current/v1/sensor_cache/prepare_read?organization=MYORG&project=MYORG_MYREPONAME | time=368ms
##[error]19:58:08.083 ERROR: Failed to prepare download of the sensor cache
org.sonar.api.utils.MessageException: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator
##[debug]Processed: ##vso[task.logissue type=error;]19:58:08.083 ERROR: Failed to prepare download of the sensor cache%0Aorg.sonar.api.utils.MessageException: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator
19:58:08.083 ERROR: Failed to prepare download of the sensor cache
org.sonar.api.utils.MessageException: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator

And then further on in the same pipeline execution…

19:58:44.975 DEBUG: GET 403 https://ea6ne4j2sb.execute-api.eu-central-1.amazonaws.com/current/v1/sensor_cache/prepare_write?organization=MYORG&project=MYORG_MYREPONAME | time=323ms
##[error]19:58:44.975 ERROR: Failed to prepare write of the sensor cache
org.sonar.api.utils.MessageException: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator
##[debug]Processed: ##vso[task.logissue type=error;]19:58:44.975 ERROR: Failed to prepare write of the sensor cache%0Aorg.sonar.api.utils.MessageException: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator
19:58:44.975 ERROR: Failed to prepare write of the sensor cache
org.sonar.api.utils.MessageException: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator

Our pipelines are straightforward.

- task: SonarCloudPrepare@1
  displayName: "Prepare analysis on SonarCloud"
  inputs:
    SonarCloud: $(SonarCloud_ServiceConnectionName)
    organization: $(SonarCloud_OrganizationName)
    scannerMode: "CLI"
    configMode: "file"
    configFile: "$(System.DefaultWorkingDirectory)/pipelines/sonar-project.properties"
    extraProperties: |
      sonar.projectVersion=$(Build.BuildNumber)

- task: SonarCloudAnalyze@1
  displayName: "Run SonarCloud analysis"

- task: SonarCloudPublish@1
  displayName: Publish SonarCloud Results
  inputs:
    pollingTimeoutSec: "300"

And the sonar-project.properties file is simple as well.

sonar.projectKey=myorg_myreponame
sonar.projectName=My-Project-Name
sonar.sources=frontend/src,backend/src
sonar.exclusions=frontend/src/testing/**,backend/src/testing/**

This other thread (403 message on analysis cache) reported the same issue a week ago (due to some recent changed by SonarCloud), but has since been resolved.

We’re using the same type of configuration. Azure DevOps (online, not server), the SonarCloud ADO extension/tasks, and a Service Connection.

Hey there,

We are experiencing issues with this new feature, recently deployed on SonarCloud. My colleagues and I are working on it, and we will deploy this week some fixes.
Even if this error should not make the scan fail, sorry for the inconvenience.

To help with the investigation, could you please tell me which permissions the user running the analysis has? (ie. the user the Sonar token belongs to), at the organization level, and at the project level?

Thanks in advance,
Claire

Hi Claire,

The token was generated by an Administrator in Sonar Cloud.

We followed the Getting started with Azure DevOps documentation, to configure the Service Account with the permissions required.

Hi,

We deployed yesterday a fix that significantly decreases the amount of 403 errors, according to our internal monitoring.
Could you tell me if you are still impacted or not?

Thanks in advance,
Claire

We have started getting the 403s yesterday. It does not prevent the pipeline from running and the SonarCloudAnalyze does run as expected. I can also see from my SonarCloud page that the token is being used.

We are using Azure DevOps and a YAML pipeline. The SonarCloudPrepare task looks like this

task: SonarCloudPrepare@1
inputs:
SonarCloud: ‘Sonarcloud Connection’
organization: ‘ourorg’
scannerMode: ‘MSBuild’
projectKey: ‘OurOrg_OurApplication’
projectName: ‘OurApplication’
projectVersion: $(fullBuildVersionString)
extraProperties: |
sonar.cs.opencover.reportsPaths=$(Common.TestResultsDirectory)*.opencover.xml
sonar.exclusions=\Stuff.Android.Bindings**,\Stuff.Touch.Bindings**
sonar.coverage.exclusions=\Us.Devices.Mir.Droid*.cs,\Views***.cs,\Us.Devices.Mir.Fake*.cs,\Stuff.Android.Bindings*.cs
sonar.verbose=true

The user whose account the token came from has the following permissions

Administer
Quality Gates, Quality Profiles

Execute Analysis
Yes

Create
Projects

@Claire_Villard do you want me to open this as a new post or is it OK to reply to this thread?

Thanks

Pat

Hi,

Could you open a new thread please?
You can also include there the debug logs produced by the scan step, they’ll be needed for investigation anyway.

Thanks
Claire

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