Help with following error... "Could not find a default branch to fall back on."

Hi,
I’m pulling my heair out with this issue. I’m getting ‘Could not find a default branch to fall back on.’. I’ve turned on debug mode and pasted the details below. Please help, It’s killing me.

Nick

  • ALM used - Azure DevOps
  • CI system used - Azure DevOps
  • Languages of the repository: Typescript
	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:51)
	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:49)
	... 34 more
Caused by: Could not find a default branch to fall back on.
07:05:33.658 ERROR: 
07:05:33.658 ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:51)
	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)

Hi @Nick_Raphael and welcome to the community !

Do you use the Azure DevOps extension for SonarCloud ?

Mickaël

Thanks for the welcome. So, I started a new job and the first thing I have to do is hook our react applications Devops build up to sonarcloud. I’ve got npm running test and generating codecoverage report. But can’t seem to publish it up to the cloud. Our other backend dotnet builds are working fine.

I believe we are using the extension. The build is in yaml format.

Can you please double check the organization name and the projectKey ? Most of the error that we had with this message came from a misconfiguration of those properties.

Thanks

They seem fine. The .org name is correct for sure. But can’t I pick anything for the project key and it will create that project up on sonarcloud?

You need to create the project first on SonarCloud. So then you’re sure that the projectKey you set is not already used, so then after you can properly set it on Azure DevOps.

Let me quickly try that. I was told that the project would be automatically created. Oh well.

It can work for some cases, but this will be deprecated soon and dropped once we will have the binding between Azure DevOps and SonarCloud organization/projects.

And also, are you analyzing the default branch of the repository at first ?

1 Like

No, I’m analysing a branch off master. Does that change things?

Yep, If it’s a new project, then you need to analyze the default branch of the repo. I think that it needs to be master at first, then you can change in on SonarCloud to reflect your configuration if it’s not the case.

1 Like

Holy crap, it worked!!! But I’m seeing this now…

“master” branch has not been analyzed yet.

1 Like

I’ll push to master…

I’m getting closer. With your help, I managed to get my stuff up into sonarCloud. Can I ask one followup question though.

What’s the difference between cliSources and sonar.tests? If I set both to ‘src’ it blows out my files beyond our limit.

cliSources: ‘src/client’
extraProperties: |
sonar.tests=src/client

cliSources is actually sonar.sources, which is a list of paths where your sources are.
sonar.tests contains paths where your test sources file are.

Both can target the same directory, so then you’ll have also your test files analyzed by the scanners and raising issues if you need to.

You can check inclusions/exclusions patterns if you need : https://sonarcloud.io/documentation/project-administration/narrowing-the-focus/

HTH,

1 Like

Worked like a charm. Can’t thank you enough. You’re the best.

3 Likes

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