Intermittent "Could not find default branch" error during SonarScan

We’ve been encountering a perplexing intermittent issue with our SonarQube/SonarCloud setup over the past few days, and we’re hoping the community might have some insights.

Problem Description:

When running sonar-scanner (specifically via sonar-maven-plugin:3.11.0.3922 as shown in the log), we occasionally receive an error indicating that the default branch for a project cannot be found. The exact error message is:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.11.0.3922:sonar (default-cli) on project cxos-cms: Could not find a default branch for project with key 'circles4_cxos-cms'. Make sure project exists.

What’s puzzling:

  1. Project Exists: When we check the SonarCloud UI (or SonarQube UI, if applicable), the project with the specified key (‘circles4_cxos-cms’ in the example) is present, and its default branch is correctly configured and visible.
  2. Self-Resolving: The most perplexing aspect is that this issue seems to resolve itself after a short period. If we retry the sonar-scan a few minutes later, it typically works without any problems. This suggests a transient state rather than a persistent misconfiguration.

Context:

  • Sonar Scanner: sonar-maven-plugin:3.11.0.3922
  • Sonar Platform: SonarCloud
  • Default Branch: The default branch is correctly set in the Sonar UI.

Has anyone else experienced similar intermittent “default branch not found” errors that resolve themselves? Any suggestions on how to further diagnose this or potential root causes we might be overlooking would be greatly appreciated.

Thank you in advance for your help!

Hello,

Can you share DEBUG-level logs in my DM inbox? For example:

mvn ... -X

Also, Is there any reason to use 3.11 of our plugin, considering that 5.11 is available?

The issue is not currently occurring. It was observed intermittently for a couple of days about two weeks ago. As a result, we are unable to enable debug logs retroactively. as for the plugin versions the issue was seen across all lanugages (java, go , js, ts) so i dont thinkk plugin version would be problem
Logs for non java project
09:28:47.122 INFO Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties
09:28:47.125 INFO Project root configuration file: /builds/circles4/pods/countryx/apps/cxos-notify/sonar-project.properties
09:28:47.140 INFO SonarScanner CLI 6.2.1.4610
09:28:47.142 INFO Java 17.0.12 Amazon.com Inc. (64-bit)
09:28:47.142 INFO Linux 5.15.0-306.177.4.el8uek.x86_64 amd64
09:28:47.228 INFO User cache: /builds/circles4/pods/countryx/apps/cxos-notify/.sonar/cache
09:28:48.418 INFO JRE provisioning: os[linux], arch[x86_64]
09:28:52.601 INFO Communicating with SonarCloud
09:28:52.858 INFO Starting SonarScanner Engine…
09:28:52.858 INFO Java 17.0.11 Eclipse Adoptium (64-bit)
09:28:53.638 INFO Load global settings
09:28:54.032 INFO Load global settings (done) | time=395ms
09:28:54.036 INFO Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu
09:28:54.288 INFO Loading required plugins
09:28:54.288 INFO Load plugins index
09:28:54.469 INFO Load plugins index (done) | time=181ms
09:28:54.469 INFO Load/download plugins
09:28:56.357 INFO Load/download plugins (done) | time=1888ms
09:28:56.781 INFO Found an active CI vendor: ‘Gitlab CI’
09:28:56.790 INFO Load project settings for component key: ‘circles4_cxos-notify’
09:28:57.091 INFO Process project properties
09:28:57.099 INFO Project key: circles4_cxos-notify
09:28:57.100 INFO Base dir: /builds/circles4/pods/countryx/apps/cxos-notify
09:28:57.100 INFO Working dir: /builds/circles4/pods/countryx/apps/cxos-notify/.scannerwork
09:28:57.104 INFO Load project branches
09:28:57.302 INFO Load project branches (done) | time=198ms
09:28:57.305 INFO Check ALM binding of project ‘circles4_cxos-notify’
09:28:57.496 INFO Detected project binding: NONEXISTENT
09:28:57.496 INFO Check ALM binding of project ‘circles4_cxos-notify’ (done) | time=192ms
09:28:57.497 INFO Load project pull requests
09:28:57.672 INFO Load project pull requests (done) | time=175ms
09:28:57.674 INFO Load branch configuration
09:28:57.675 INFO Auto-configuring pull request 991
09:28:57.681 ERROR Could not find a default branch for project with key ‘circles4_cxos-notify’. Make sure project exists.

Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.11.0/maven-compiler-plugin-3.11.0.jar (66 kB at 9.4 MB/s)
[INFO] 09:16:16.404 Default locale: “en”, source code encoding: “UTF-8”
[INFO] 09:16:16.981 Load global settings
[INFO] 09:16:18.685 Load global settings (done) | time=1705ms
[INFO] 09:16:18.688 Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu
[INFO] 09:16:18.841 Loading required plugins
[INFO] 09:16:18.841 Load plugins index
[INFO] 09:16:19.140 Load plugins index (done) | time=299ms
[INFO] 09:16:19.141 Load/download plugins
[INFO] 09:16:19.180 Load/download plugins (done) | time=38ms
[INFO] 09:16:21.739 Found an active CI vendor: ‘Gitlab CI’
[INFO] 09:16:21.745 Load project settings for component key: ‘circles4_cxos-bssmw’
[INFO] 09:16:22.213 Process project properties
[INFO] 09:16:22.222 Project key: circles4_cxos-bssmw
[INFO] 09:16:22.223 Base dir: /builds/circles4/pods/countryx/apps/cxos-bssmw
[INFO] 09:16:22.223 Working dir: /builds/circles4/pods/countryx/apps/cxos-bssmw/target/sonar
[INFO] 09:16:22.226 Load project branches
[INFO] 09:16:22.811 Load project branches (done) | time=585ms
[INFO] 09:16:22.816 Check ALM binding of project ‘circles4_cxos-bssmw’
[INFO] 09:16:23.735 Detected project binding: NONEXISTENT
[INFO] 09:16:23.735 Check ALM binding of project ‘circles4_cxos-bssmw’ (done) | time=919ms
[INFO] 09:16:23.736 Load project pull requests
[INFO] 09:16:24.371 Load project pull requests (done) | time=635ms
[INFO] 09:16:24.374 Load branch configuration
[INFO] 09:16:24.376 Auto-configuring branch feature/CXOS-7893_addingProductPriorityInSubscription
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Skipping CXOS Bssmw
[INFO] This project has been banned from the build due to previous failures.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 39.226 s
[INFO] Finished at: 2025-06-03T09:16:24Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.11.0.3922:sonar (default-cli) on project cxos-bssmw: Could not find a default branch for project with key ‘circles4_cxos-bssmw’. Make sure project exists. → [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] MojoExecutionException - Apache Maven - Apache Software Foundation
make: *** [Makefile:48: sonartest] Error 1

Hello,

OK, please update this topic if it reoccurs.

DEBUG logs will probably be more helpful because of the additional request/request lines; e.g.,

11:28:54.201 INFO  Load project settings for component key: 'waynekhan_juice-shop'
11:28:54.202 DEBUG --> GET https://sonarcloud.io/api/settings/values.protobuf?component=waynekhan_juice-shop
11:28:54.565 DEBUG <-- 200 https://sonarcloud.io/api/settings/values.protobuf?component=waynekhan_juice-shop (363ms, unknown-length body)
11:28:54.566 INFO  Load project settings for component key: 'waynekhan_juice-shop' (done) | time=365ms
11:28:54.574 INFO  Process project properties
11:28:54.574 DEBUG Process project properties (done) | time=1ms
11:28:54.581 INFO  Project key: waynekhan_juice-shop

Hi Wayne,
we encountered the issue again, i cannot send you a dm or post the debug logs here a i am a new member, can you please let me know your email id via dm so i could email it to you