Error during SonarScanner execution when trying to load branch configuration

Error during SonarScanner execution when trying to load branch configuration.

  • ALM used: AzureDevOps Pipeline
  • CI system used: AzureDevOps Pipeline
  • Languages of the repository: C#, Javascript/Typescript

Hello community,

After submitting a pull request, the SonarScanner started failing with a few errors when trying to load the branch configuration. The last errors in the logs are

Caused by: java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0
*/(branch|releases)/*
^
	at java.base/java.util.regex.Pattern.error(Pattern.java:2027)
	at java.base/java.util.regex.Pattern.sequence(Pattern.java:2202)
	at java.base/java.util.regex.Pattern.expr(Pattern.java:2068)
	at java.base/java.util.regex.Pattern.compile(Pattern.java:1782)
	at java.base/java.util.regex.Pattern.<init>(Pattern.java:1428)
	at java.base/java.util.regex.Pattern.compile(Pattern.java:1068)
	at java.base/java.util.regex.Pattern.matches(Pattern.java:1173)
	at java.base/java.lang.String.matches(String.java:2024)
	at com.sonarsource.branch.BranchConfigurationBuilderImpl.getBranchType(BranchConfigurationBuilderImpl.java:88)
	at com.sonarsource.branch.BranchConfigurationBuilderImpl.build(BranchConfigurationBuilderImpl.java:52)
	at com.sonarsource.branch.BranchConfigurationLoaderImpl.load(BranchConfigurationLoaderImpl.java:69)
	at org.sonar.scanner.scan.branch.BranchConfigurationProvider.provide(BranchConfigurationProvider.java:33)
##[error]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.picocontainer.injectors.MethodInjector.invokeMethod(MethodInjector.java:129)
	at org.picocontainer.injectors.MethodInjector.access$000(MethodInjector.java:39)
	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.picocontainer.injectors.MethodInjector.invokeMethod(MethodInjector.java:129)
	at org.picocontainer.injectors.MethodInjector.access$000(MethodInjector.java:39)
##[error]at org.picocontainer.injectors.MethodInjector$2.run(MethodInjector.java:113)
	at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
	at org.picocontainer.injectors.MethodInjector$2.run(MethodInjector.java:113)
	at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
##[error]at org.picocontainer.injectors.MethodInjector.decorateComponentInstance(MethodInjector.java:120)
	at org.picocontainer.injectors.CompositeInjector.decorateComponentInstance(CompositeInjector.java:58)
	at org.picocontainer.injectors.MethodInjector.decorateComponentInstance(MethodInjector.java:120)
	at org.picocontainer.injectors.CompositeInjector.decorateComponentInstance(CompositeInjector.java:58)
##[error]at org.picocontainer.injectors.Reinjector.reinject(Reinjector.java:142)
	at org.picocontainer.injectors.ProviderAdapter.getComponentInstance(ProviderAdapter.java:96)
	at org.picocontainer.injectors.Reinjector.reinject(Reinjector.java:142)
	at org.picocontainer.injectors.ProviderAdapter.getComponentInstance(ProviderAdapter.java:96)
##[error]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)
	... 48 more
	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)
	... 48 more
##[error]ERROR:
ERROR: 
##[error]The SonarScanner did not complete successfully
The SonarScanner did not complete successfully
##[error]11:59:40.281  Post-processing failed. Exit code: 1
11:59:40.281  Post-processing failed. Exit code: 1
##[error]The process 'C:\agent-aws\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.32.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1

See the raw log file attached.
SonarScanner.log (41.3 KB)

Another thing we find out. Scanning a pull request merge request will work ok, but scanning the working branch directly will throw these errors.

Hi,

Could you share this project’s Long-lived branches pattern? You’ll find it at the top-right of the project’s Branches page.

Based on the error message, it looks like it starts with *? What happens if you remove that?

 
Ann

Thanks Ann!
Someone on the team updated the pattern!
Fixed the regex and that took care of the errors.