SonarCloud PR analysis fails with Could not find the pullrequest with key when using Azure DevOps PR

Hi SonarCloud team,

I’m facing an issue with Pull Request analysis in SonarCloud using Azure DevOps pipelines.
Even though the PR exists in Azure DevOps and the pipeline is triggered correctly, SonarCloud fails with:

ERROR Could not find the pullrequest with key ‘27369’

Environment

  • CI: Azure DevOps Pipelines

  • Repository: Azure Repos (Git)

  • Sonar: SonarCloud

  • Scanner: SonarCloudPrepare@4 / SonarCloudAnalyze@4 (CLI mode)

  • Project Type: React / TypeScript

  • Java Version: JDK 21

  • OS: ubuntu-latest agent

Azure DevOps PR Variables (verified in logs)

system.pullRequest.pullRequestId : 27369
system.pullRequest.sourceBranch : refs/heads/xxxxxxx/feature-pipeline
system.pullRequest.targetBranch : refs/heads/xxxxxx
system.pullRequest.targetBranchName : <xxxxx>

What I have tried

  • Switching between configMode: file and configMode: manual

  • Removing all sonar.pullrequest.* properties

  • Verifying PR exists and pipeline is triggered in PR context

  • Enabling system.debug=true

  • Confirmed SonarCloud project key matches pipeline config

Expected Behavior

SonarCloud should:

  • Automatically detect PR metadata from Azure DevOps

  • Analyze the PR

  • Decorate the PR with analysis results

Actual Behavior

SonarCloud attempts to fetch the PR via alm_integration/show_pullrequest API and returns 404, causing the pipeline to fail.

Hi,

Many systems will return a 404 error (i.e. what you’ve asked for doesn’t exist) rather than a 403 error, thus admitting that the resource exists but you just don’t have access to it.

You should double-check the PAT you’ve configured SonarQube Cloud with, both at the organization and project levels.

 
Ann

1 Like

Hi Ann,

Thank you for your suggestion.

You were absolutely right — the issue was related to the organization-level PAT configuration.

After reviewing the DevOps Platform Integration settings in SonarQube Cloud, we discovered that the organization token was either invalid/expired or did not have the correct permissions. Once we updated the PAT at the organization level with a valid token (with appropriate Azure DevOps permissions), the PR analysis started working correctly and the 404 error was resolved.

The project-level configuration was fine — the root cause was specifically the organization-level token.

Thanks again for pointing us in the right direction!

Best regards,
Himanshu Kapoor

1 Like

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