Could not find the pullrequest with key X

  • ALM used - Azure DevOps
  • CI system used - Azure DevOps
  • Scanner command used when applicable (private details masked)
       - task: SonarCloudPrepare@1
         inputs:
           SonarCloud: "SonarCloud"
           organization: "<redacted>"
           scannerMode: "CLI"
           configMode: "manual"
           cliProjectKey: "<redacted>"
           cliProjectName: "<redacted>"
           extraProperties: "sonar.javascript.lcov.reportPaths=**/coverage/lcov.info"

       - task: SonarCloudAnalyze@1
         inputs:
           jdkversion: "JAVA_HOME_17_X64"

       - task: SonarCloudPublish@1
         inputs:
           pollingTimeoutSec: "300"
  • Languages of the repository
    C#, javascript
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
/home/vsts/work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.43.2/sonar-scanner/bin/sonar-scanner
INFO: Scanner configuration file: /home/vsts/work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.43.2/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: /home/vsts/work/1/s/sonar-project.properties
INFO: SonarScanner 4.8.1.3023
INFO: Java 17.0.10 Eclipse Adoptium (64-bit)
INFO: Linux 6.2.0-1019-azure amd64
INFO: User cache: /home/vsts/.sonar/cache
INFO: Analyzing on SonarCloud
INFO: Default locale: "en", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=162ms
INFO: Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu
INFO: User cache: /home/vsts/.sonar/cache
INFO: Loading required plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=244ms
INFO: Load/download plugins
INFO: Load/download plugins (done) | time=748ms
INFO: Found an active CI vendor: 'Azure DevOps'
INFO: Load project settings for component key: '<redacted>'
INFO: Load project settings for component key: '<redacted>' (done) | time=59ms
INFO: Process project properties
INFO: Project key:<redacted>
INFO: Base dir: /home/vsts/work/1/s
INFO: Working dir: /home/vsts/work/1/s/.scannerwork
INFO: Load project branches
INFO: Load project branches (done) | time=76ms
INFO: Check ALM binding of project '<redacted>'
INFO: Detected project binding: BOUND
INFO: Check ALM binding of project '<redacted>' (done) | time=44ms
INFO: Load project pull requests
INFO: Load project pull requests (done) | time=94ms
INFO: Load branch configuration
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
ERROR: Caused by: Error 404 on https://sonarcloud.io/api/alm_integration/show_pullrequest?project=<redacted>&pullrequestKey=1008 : {"errors":[{"msg":"Unable to find the pullrequest with key \u00271008\u0027"}]}
ERROR: 
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
##[error]The process '/home/vsts/work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.43.2/sonar-scanner/bin/sonar-scanner' failed with exit code 2

This error started happening all of a sudden. No change on our side triggered it, but for multiple projects, the sonar pipeline started failing. Why is this happening and what can we do?

I already tried:

  • Recreating the service connection in Azure Devops with a new token from SonarCloud
  • Getting a new PAT in Azure DevOps and setting it in SonarCloud Pull Request settings. (see screenshot)

It hasn’t been working for a week now and all our pipelines are blocked because of it, help!

1 Like

Hey there.

This reminds me of a similar case with a user right now where the organization-level token was invalid, and fixing it solved the issue. While the project-level token should be taking precedence, can you check your global organization settings to see if it shows the token as valid or not?

1 Like

That was indeed the case! This is what the key looked like in Organization Settings:

I updated it and now it’s fixed. Thanks!

2 Likes