ERROR: Could not find the pullrequest

Hi,
We are using Gitlab and getting below error for Pull Request. It only happen on one of our pipeline.

INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 20.646s
ERROR: Error during SonarScanner execution
ERROR: Could not find the pullrequest with key '194'
ERROR: Caused by: Error 404 on https://sonarcloud.io/api/alm_integration/show_pullrequest?project=project_name&pullrequestKey=194 : {"errors":[{"msg":"Unable to find the pullrequest with key \"}]}
ERROR: 
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

Any advice why is this happened?

Hello @Herfan_Yusano and welcome to our Community!

This error means that SonarCloud was not able to retrieve this pull request from the repository. Could you check if a pull request with this key (194) still exists and it is not already closed?
If it still exists and is not closed, can you tell us how is your pipeline configured?
Everything that is not a pull request is successfully analysed?
You told that this happens only at one of your pipelines, could you check for configuration mistakes? A simple wrong project key could also lead to this error, since a wrong repository will not have the pull request as well.

Hello @Alexandre_Holzhey, thank you for the feedback!

The pull request is not closed, and yes everything that is not a pull request is successfully analysed.
My mistake, I mean this only happened on one of our repository.
These are the stages

stages:
  - .pre
  - test
  - sonar
  - build
  - container-scanning
  - deploy

and this is the stage where sonar script executed

sonar_test:
  stage: sonar
  allow_failure: false
  extends: .sonarqube
  script:
    - sonar-scanner -X
      -Dsonar.tests=.
      -Dsonar.test.inclusions=$SONAR_TEST_INCLUSIONS
      -Dsonar.test.exclusions=$SONAR_TEST_EXCLUSIONS
      -Dsonar.go.coverage.reportPaths=coverage.out
      -Dsonar.qualitygate.wait=true
      -Dsonar.sources="."
      -Dsonar.projectKey=$SONAR_PROJECT_KEY
      -Dsonar.projectName=$SONAR_PROJECT_NAME
      -Dsonar.projectVersion=$SONAR_PROJECT_VERSION
      -Dsonar.organization=$SONAR_ORGANIZATION
      -Dsonar.exclusions=$SONAR_EXCLUSIONS
      -Dsonar.coverage.exclusions=$SONAR_COVERAGE_EXCLUSIONS
      -Dsonar.cpd.exclusions=$SONAR_CPD_EXCLUSIONS
      -Dsonar.go.golangci-lint.reportPaths=checkstyle.xml

We have confirmed that the project key is correct.

We tried:

  • re-creating the project key, it failed
  • copy the repository and use different key, scan on pullrequest ran successfully.

attaching debug log

11:15:28.573 INFO: EXECUTION FAILURE
11:15:28.573 INFO: ------------------------------------------------------------------------
11:15:28.573 INFO: Total time: 49.953s
11:15:28.609 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.filesystem.InputComponentStore
11:15:28.609 INFO: Final Memory: 7M/76M
11:15:28.609 INFO: ------------------------------------------------------------------------
	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:52)
	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
	at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
	at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
	at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
	at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)
	at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)
	at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
	at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
	at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
	at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
	at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
	at org.picocontainer.DefaultPicoContainer.instantiateComponentAsIsStartable(DefaultPicoContainer.java:1034)
	at org.picocontainer.DefaultPicoContainer.addAdapterIfStartable(DefaultPicoContainer.java:1026)
	at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1003)
	at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:122)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:128)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:58)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:52)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at com.sun.proxy.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.IllegalStateException: Unable to load component interface org.sonar.scanner.scan.branch.BranchConfiguration
	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:52)
	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
	at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
	at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
	at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
	at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)
	at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)
	at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
	at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
	at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
	at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
	at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
	at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:50)
	... 34 more
Caused by: Could not find the pullrequest with key '194'
Caused by: org.sonarqube.ws.client.HttpException: Error 404 on https://sonarcloud.io/api/alm_integration/show_pullrequest?project=project_name&pullrequestKey=194 : {"errors":[{"msg":"Unable to find the pullrequest with key \u0027201\u0027"}]}

Hello Herfan,

Is your project correctly bound to the right repo on Gitlab ? Can you see the little Gitlab icon next to the project name on SonarCloud ?

Hello @Gregoire_Aubert,

Yes, it is bound to the right repo on Gitlab.