Could not find a default branch to fall back on

I’m getting the following error when running official action on GithubActions:
“Could not find a default branch to fall back on”

  • ALM: Github
  • CI system used: Github Actions
  • Scanner command used: Official GH Action
  • Languages of the repository: c#
  • Error observed: Could not find a default branch to fall back on

Hi @adanlobato-scopely,

This could be related to a misconfiguration of the project key or organization. Could you check if the project key you provided matches the project key on SonarCloud?

If the key is correctly configured could you share the log output of the GitHub action?

I’m experiencing the same issue.

The project “Sirups.Essentials.Mvc” which should be visible here:

From the github action located here:

I get the following error in the analyze fase (
INFO: Total time: 31.652s
ERROR: Error during SonarScanner execution
INFO: Final Memory: 25M/125M
ERROR: Could not find a default branch to fall back on.
INFO: ------------------------------------------------------------------------
The SonarQube Scanner did not complete successfully
06:07:21.573 Post-processing failed. Exit code: 1
##[error]Process completed with exit code 1.

Hi @CoolMcgrrr and welcome to the community !

Can you double check that your main branch is the default one on SonarCloud ? If you go to Administration -> Branches and pull request, there should be a label “MAIN BRANCH” beside the name of your default branch.


Thanks a bundle! :slight_smile:
I have just verified that my “MAIN BRANCH” is “main”. (Which is as expected)
The action failed on the “main” branch.

EDIT: I think what I wrote was a bit unclear. So just to be on the safe side.
The “Thanks a bundle” was for welcoming me to the community.
As far as I can tell the project is correctly setup in SonarCloud. But I am still getting the error.

Thanks ! How did you create the project on SonarCloud ? Manually, or by choosing the repository on the UI (what we call “onboarding”) ?

I created the project by choosing the repository.

I tried running my Github Action before it was created. (My expectation was that it would be created automatically)
Since that didn’t happen I created it by choosing the repository

Yes because the log suggests that the binding (when the project was created by selecting the repo) was not created at the time you ran the analysis.

So did you tried again with the new setup of your project ? Is it still failing ?

I tried deleting the project in SonarCloud and tried running the action again. I still get “Could not find a default branch to fall back on.”
I can’t see anything special about my repository. I have a branch protection rule preventing pushes to the release branch, but that shouldn’t be relevant here since my Main branch is “main” and the current branch I’m running on is “main”.

If I create it manually without “onboarding” I’m able to get it to work.
However this sets it up with a “master” default branch and my “main” branch as a “secondary” branch.
Is this some issue with SonarQube requiring a “master” branch or something like that?

I tried creating it all over again with the “onboarding” feature (which sets up my branches as they should be) and I get the “Could not find a default branch to fall back on.”.

Hi @CoolMcgrrr

I think you may need to provide the -k:{myProjectKey} in your ci.yml file directly when invoking the Scanner for MSBuild, that should work that way.


A post was split to a new topic: Have two repos (GH and GitLab) under one SonarCloud org

A post was split to a new topic: “Could not find a default branch to fall back on” GitLab Error

The wrong sonar.projectKey was the issue on my side.

My project is here GitHub - n13org/jekyll-kw-loremipsum: LoremIpsum is a jekyll plugin. You can get some dummy text for your webpage, without copy & pasting the Lorem Ipsum words yourself..

I have set up sonar as an organization and my projectKey is jekyll-kw-loremipsum.
And I saw in the URL: that the org and the projectkey are combined.

my “wrong” projectKey was: sonar.projectKey=jekyll-kw-loremipsum I switched to sonar.projectKey=n13org_jekyll-kw-loremipsum (so i prefixed my project key with the org) and the scan was successfully done.