ERROR: Could not find the pull request - SonarCloud Azure DevOps PR integration

  • ALM: Azure DevOps
  • CI system: Azure DevOps pipeline
  • Error observed: (Azure DevOps pipeline logs)
INFO: ------------------------------------------------------------------------

##[error]ERROR: Error during SonarScanner execution

ERROR: Error during SonarScanner execution

##[error]ERROR: Could not find the pullrequest with key 'XXX

ERROR: Caused by: Error 404 on https://sonarcloud.io/api/alm_integration/show_pullrequest?XXX

ERROR:

ERROR: Could not find the pullrequest with key XXX

ERROR: Caused by: Error 404 on https://sonarcloud.io/api/alm_integration/show_pullrequest?XXX

ERROR:

##[error]The SonarScanner did not complete successfully

We are experiencing the above error when trying to enable pull request integration with Azure DevOps for one of our private projects by following the steps listed in the documentation.
The analysis triggered by the pull request fails and no pull-request is listed for the project on SonarCloud.

Many thanks

This issue started happening for us as well starting about a week ago. There were no changes to the pipeline or the Sonar configuration. The analysis runs fine, and when it’s run on the main branch it completes with no problems. This is specifically an issue where it is not creating the PR on the Sonar side and getting a 404.

This also displays a stack trace that starts with:

##[error]16:11:36.961 ERROR: Error during SonarScanner execution
16:11:36.961 ERROR: Error during SonarScanner execution
##[error]java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.filesystem.InputComponentStore
java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.filesystem.InputComponentStore

but the root of this is the error noted in the post above

Caused by: Could not find the pullrequest with key 'XXX'
Caused by: org.sonarqube.ws.client.HttpException: Error 404 on https://sonarcloud.io/api/alm_integration/show_pullrequest?project=YYY&pullrequestKey=XXX : {"errors":[{"msg":"Unable to find the pullrequest with key \u0027XXX\u0027"}]}

Does anyone have any insights?

Posting some relevant debug information from the failing analysis task: as @Jason_Donnell said there are other errors but the root cause is the 404 on the pull request retrieval. I didn’t find anything related to PR creation on SonarCloud in the logs

sonar.organization=ZZZ
sonar.host.url=https://sonarcloud.io/
sonar.projectKey=XXX
sonar.projectName=XYZ
sonar.projectVersion=1.2.3.4
sonar.pullrequest.key=YYY
sonar.pullrequest.base=develop
sonar.pullrequest.branch=feature/test-sonarcloud-pr-integration
sonar.pullrequest.provider=vsts
sonar.pullrequest.vsts.instanceUrl=https://dev.azure.com/ZZZ/
sonar.pullrequest.vsts.project=WWW
sonar.pullrequest.vsts.repository=XXX
sonar.scanner.metadataFilePath=C:\\agent\\_work\\_temp\\sonar\\24186\\28914c87-9f75-fb0b-825d-836d8576a314\\report-task.txt
sonar.visualstudio.enable=false

...

2023-10-13T14:04:24.0883118Z 16:04:24.084 INFO: Load project branches
2023-10-13T14:04:24.2006442Z 16:04:24.200 DEBUG: GET 200 https://sonarcloud.io/api/project_branches/list?project=XXX | time=115ms
2023-10-13T14:04:24.2043343Z 16:04:24.203 INFO: Load project branches (done) | time=119ms
2023-10-13T14:04:24.2069127Z 16:04:24.206 INFO: Check ALM binding of project 'XXX'
2023-10-13T14:04:24.2815110Z 16:04:24.280 DEBUG: GET 200 https://sonarcloud.io/api/alm_integration/is_project_bound?project=XXX | time=74ms
2023-10-13T14:04:24.2833801Z 16:04:24.283 INFO: Detected project binding: BOUND
2023-10-13T14:04:24.2836163Z 16:04:24.283 INFO: Check ALM binding of project 'XXX' (done) | time=77ms
2023-10-13T14:04:24.2857828Z 16:04:24.285 INFO: Load project pull requests
2023-10-13T14:04:24.3587883Z 16:04:24.358 DEBUG: GET 200 https://sonarcloud.io/api/project_pull_requests/list?project=XXX | time=73ms
2023-10-13T14:04:24.3612766Z 16:04:24.360 INFO: Load project pull requests (done) | time=75ms
2023-10-13T14:04:24.3642235Z 16:04:24.360 INFO: Load branch configuration
2023-10-13T14:04:24.3648434Z 16:04:24.360 DEBUG: Found manual configuration of branch/PR analysis. Skipping automatic configuration.
2023-10-13T14:04:24.5971295Z 16:04:24.596 DEBUG: GET 404 https://sonarcloud.io/api/alm_integration/show_pullrequest?project=XXX&pullrequestKey=YYY | time=236ms
2023-10-13T14:04:24.6027256Z 16:04:24.602 INFO: ------------------------------------------------------------------------
2023-10-13T14:04:24.6027627Z 16:04:24.602 INFO: EXECUTION FAILURE
2023-10-13T14:04:24.6028065Z 16:04:24.602 INFO: ------------------------------------------------------------------------
2023-10-13T14:04:24.6029116Z 16:04:24.602 INFO: Total time: 3.086s
2023-10-13T14:04:24.6216859Z 16:04:24.621 INFO: Final Memory: 16M/57M
2023-10-13T14:04:24.6217751Z 16:04:24.621 INFO: ------------------------------------------------------------------------
2023-10-13T14:04:24.6222242Z ##[error]16:04:24.621 ERROR: Error during SonarScanner execution
2023-10-13T14:04:24.6222702Z ##[debug]Processed: ##vso[task.logissue type=error;]16:04:24.621 ERROR: Error during SonarScanner execution
2023-10-13T14:04:24.6223012Z 16:04:24.621 ERROR: Error during SonarScanner execution
2023-10-13T14:04:24.6223855Z ##[error]java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.filesystem.InputComponentStore
2023-10-13T14:04:24.6224258Z ##[debug]Processed: ##vso[task.logissue type=error;]java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.filesystem.InputComponentStore
2023-10-13T14:04:24.6224627Z java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.filesystem.InputComponentStore
2023-10-13T14:04:24.6229860Z ##[error]at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:52)
2023-10-13T14:04:24.6230501Z ##[debug]Processed: ##vso[task.logissue type=error;]at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:52)
2023-10-13T14:04:24.6247145Z 	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:52)
...
2023-10-13T14:04:24.6330121Z Caused by: Could not find the pullrequest with key 'YYY'
2023-10-13T14:04:24.6330748Z ##[error]Caused by: org.sonarqube.ws.client.HttpException: Error 404 on https://sonarcloud.io/api/alm_integration/show_pullrequest?project=XXX&pullrequestKey=YYY : {"errors":[{"msg":"Unable to find the pullrequest with key \u0027YYY\u0027"}]}
2023-10-13T14:04:24.6331372Z ##[debug]Processed: ##vso[task.logissue type=error;]Caused by: org.sonarqube.ws.client.HttpException: Error 404 on https://sonarcloud.io/api/alm_integration/show_pullrequest?project=XXX&pullrequestKey=YYY : {"errors":[{"msg":"Unable to find the pullrequest with key \u0027YYY\u0027"}]}
2023-10-13T14:04:24.6332094Z Caused by: org.sonarqube.ws.client.HttpException: Error 404 on https://sonarcloud.io/api/alm_integration/show_pullrequest?project=XXX&pullrequestKey=YYY : {"errors":[{"msg":"Unable to find the pullrequest with key \u0027YYY\u0027"}]}
2023-10-13T14:04:24.6332873Z ##[error]at org.sonarqube.ws.client.BaseResponse.failIfNotSuccessful(BaseResponse.java:22)
	at org.sonar.scanner.bootstrap.DefaultScannerWsClient.failIfUnauthorized(DefaultScannerWsClient.java:88)
...
2023-10-13T14:04:24.9980308Z Process returned exit code 1
2023-10-13T14:04:24.9983761Z ##[error]The SonarScanner did not complete successfully
2023-10-13T14:04:24.9984266Z ##[debug]Processed: ##vso[task.logissue type=error;]The SonarScanner did not complete successfully
2023-10-13T14:04:24.9984647Z The SonarScanner did not complete successfully
2023-10-13T14:04:24.9989186Z ##[error]16:04:24.994  Post-processing failed. Exit code: 1
2023-10-13T14:04:24.9989558Z ##[debug]Processed: ##vso[task.logissue type=error;]16:04:24.994  Post-processing failed. Exit code: 1
2023-10-13T14:04:24.9990269Z 16:04:24.994  Post-processing failed. Exit code: 1
2023-10-13T14:04:25.0052331Z ##[debug]Exit code 1 received from tool 'C:\agent\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.38.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2023-10-13T14:04:25.0056877Z ##[debug]STDIO streams have closed for tool 'C:\agent\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.38.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2023-10-13T14:04:25.0098556Z ##[debug]task result: Failed
2023-10-13T14:04:25.0099432Z ##[error]The process 'C:\agent\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.38.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
2023-10-13T14:04:25.0100296Z ##[debug]Processed: ##vso[task.issue type=error;]The process 'C:\agent\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.38.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
2023-10-13T14:04:25.0101697Z ##[debug]Processed: ##vso[task.complete result=Failed;]The process 'C:\agent\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.38.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
2023-10-13T14:04:25.0168676Z ##[section]Finishing: Run Code Analysis

Hi all,

I’m very sorry; this topic got lost in the shuffle. Are you still experiencing this behavior?

 
Thx,
Ann

Hi Ann

Thanks for catching up on the discussion.
Yes we are still experiencing the issue: we tried also with other DevOps projects with the same outcome.

Alberto

1 Like

Hi Alberto,

Thanks for the confirmation. I’ve referred this to the SonarCloud team.

 
Ann

Hello @alblosi

This error is commonly seen when the Private Access Token is either expired or is not set with the correct rights.
Something that happens as well, is that this token needs to be issued by an account that has the “code read & write” permission on the projects.

Can you please issue a new Private Access Token from a user with correct rights on the organization/project and follow the steps describe in this documentation : Azure DevOps | SonarCloud Docs

Best regards,

3 Likes

Hi @quentin.chevrin
Thank you for you detailed explanation: following the steps you reported solves the issue for us.
Regards

Alberto

2 Likes

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