Sonarscanner end fails by changing 1 file

Hi, we have following setup:

  • using GH
  • using the sonarscanner with the dotnet install command (resulting in SonarScanner for .NET 11.0)
  • using the default commands dotnet-sonarscanner begin and dotnet-sonarscanner end
  • code to analyze is .NET
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
  • reproducible by adding 1 additional line to the .gitattributes file to add files to LFS
  • no workaround

error we have:

16:13:27.043  INFO: SCM collecting changed files in the branch
16:13:27.299  ERROR: Error during SonarScanner Engine execution
java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.filesystem.ProjectFileIndexer
    at org.sonar.core.platform.SpringComponentContainer.getComponentByType(SpringComponentContainer.java:148)
    at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:148)
    at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:210)
    at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:189)
    at org.sonar.scanner.bootstrap.SpringScannerContainer.doAfterStart(SpringScannerContainer.java:471)
    at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:210)
    at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:189)
    at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:146)
    at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:210)
    at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:189)
    at org.sonar.scanner.bootstrap.ScannerMain.runScannerEngine(ScannerMain.java:143)
    at org.sonar.scanner.bootstrap.ScannerMain.run(ScannerMain.java:58)
    at org.sonar.scanner.bootstrap.ScannerMain.main(ScannerMain.java:42)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘jdk.internal.loader.ClassLoaders$AppClassLoader@3857f613-org.sonar.scanner.scan.filesystem.ProjectFileIndexer’: Unsatisfied dependency expressed through constructor parameter 6: Error creating bean with name ‘jdk.internal.loader.ClassLoaders$AppClassLoader@3857f613-org.sonar.scanner.scan.filesystem.FileIndexer’: Unsatisfied dependency expressed through constructor parameter 5: Error creating bean with name ‘jdk.internal.loader.ClassLoaders$AppClassLoader@3857f613-org.sonar.scanner.scan.filesystem.MetadataGenerator’: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name ‘jdk.internal.loader.ClassLoaders$AppClassLoader@3857f613-org.sonar.scanner.scan.filesystem.StatusDetection’: Unsatisfied dependency expressed through constructor parameter 1: Error creating bean with name ‘ScmChangedFiles’ defined in org.sonar.scanner.scm.ScmChangedFilesProvider: Failed to instantiate \[org.sonar.scanner.scm.ScmChangedFiles\]: Factory method ‘provide’ threw exception with message: Error while parsing attributes
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:804)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:240)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1395)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1232)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:569)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:529)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:339)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:373)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:227)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1613)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1571)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveBean(DefaultListableBeanFactory.java:564)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:393)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:386)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1290)
    at org.sonar.core.platform.SpringComponentContainer.getComponentByType(SpringComponentContainer.java:146)
    … 12 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘jdk.internal.loader.ClassLoaders$AppClassLoader@3857f613-org.sonar.scanner.scan.filesystem.FileIndexer’: Unsatisfied dependency expressed through constructor parameter 5: Error creating bean with name ‘jdk.internal.loader.ClassLoaders$AppClassLoader@3857f613-org.sonar.scanner.scan.filesystem.MetadataGenerator’: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name ‘jdk.internal.loader.ClassLoaders$AppClassLoader@3857f613-org.sonar.scanner.scan.filesystem.StatusDetection’: Unsatisfied dependency expressed through constructor parameter 1: Error creating bean with name ‘ScmChangedFiles’ defined in org.sonar.scanner.scm.ScmChangedFilesProvider: Failed to instantiate \[org.sonar.scanner.scm.ScmChangedFiles\]: Factory method ‘provide’ threw exception with message: Error while parsing attributes
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:804)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:240)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1395)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1232)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:569)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:529)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:339)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:373)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1760)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1643)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:913)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)
    … 28 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘jdk.internal.loader.ClassLoaders$AppClassLoader@3857f613-org.sonar.scanner.scan.filesystem.MetadataGenerator’: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name ‘jdk.internal.loader.ClassLoaders$AppClassLoader@3857f613-org.sonar.scanner.scan.filesystem.StatusDetection’: Unsatisfied dependency expressed through constructor parameter 1: Error creating bean with name ‘ScmChangedFiles’ defined in org.sonar.scanner.scm.ScmChangedFilesProvider: Failed to instantiate \[org.sonar.scanner.scm.ScmChangedFiles\]: Factory method ‘provide’ threw exception with message: Error while parsing attributes
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:804)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:240)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1395)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1232)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:569)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:529)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:339)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:373)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:277)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1760)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1643)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:913)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)
    … 42 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘jdk.internal.loader.ClassLoaders$AppClassLoader@3857f613-org.sonar.scanner.scan.filesystem.StatusDetection’: Unsatisfied dependency expressed through constructor parameter 1: Error creating bean with name ‘ScmChangedFiles’ defined in org.sonar.scanner.scm.ScmChangedFilesProvider: Failed to instantiate \[org.sonar.scanner.scm.ScmChangedFiles\]: Factory method ‘provide’ threw exception with message: Error while parsing attributes
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:804)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:240)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1395)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1232)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:569)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:529)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:339)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:373)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1760)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1643)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:913)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)
    … 57 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘ScmChangedFiles’ defined in org.sonar.scanner.scm.ScmChangedFilesProvider: Failed to instantiate \[org.sonar.scanner.scm.ScmChangedFiles\]: Factory method ‘provide’ threw exception with message: Error while parsing attributes
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:657)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:645)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1375)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1205)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:569)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:529)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:339)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:373)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1760)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1643)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:913)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)
    … 71 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate \[org.sonar.scanner.scm.ScmChangedFiles\]: Factory method ‘provide’ threw exception with message: Error while parsing attributes
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.lambda$instantiate$0(SimpleInstantiationStrategy.java:200)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiateWithFactoryMethod(SimpleInstantiationStrategy.java:89)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:169)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
    … 85 common frames omitted
Caused by: org.eclipse.jgit.api.errors.JGitInternalException: Error while parsing attributes
    at org.eclipse.jgit.treewalk.TreeWalk.getAttributes(TreeWalk.java:635)
    at org.eclipse.jgit.treewalk.TreeWalk.getAttributes(TreeWalk.java:589)
    at org.eclipse.jgit.diff.DiffEntry.scan(DiffEntry.java:169)
    at org.eclipse.jgit.diff.DiffEntry.scan(DiffEntry.java:110)
    at org.eclipse.jgit.diff.DiffEntry.scan(DiffEntry.java:87)
    at org.eclipse.jgit.diff.DiffFormatter.scan(DiffFormatter.java:533)
    at org.eclipse.jgit.api.DiffCommand.call(DiffCommand.java:118)
    at org.sonar.scm.git.GitScmProvider.branchChangedFiles(GitScmProvider.java:119)
    at org.sonar.scanner.scm.ScmChangedFilesProvider.loadChangedFilesIfNeeded(ScmChangedFilesProvider.java:55)
    at org.sonar.scanner.scm.ScmChangedFilesProvider.provide(ScmChangedFilesProvider.java:32)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.lambda$instantiate$0(SimpleInstantiationStrategy.java:172)
    … 88 common frames omitted
Caused by: org.eclipse.jgit.errors.MissingObjectException: Missing blob 863ab589c133ad4f8355e86bc677a19e9fddfe14
    at org.eclipse.jgit.internal.storage.file.WindowCursor.open(WindowCursor.java:138)
    at org.eclipse.jgit.treewalk.CanonicalTreeParser.loadAttributes(CanonicalTreeParser.java:393)
    at org.eclipse.jgit.treewalk.CanonicalTreeParser.findAttributes(CanonicalTreeParser.java:385)
    at org.eclipse.jgit.treewalk.CanonicalTreeParser.getEntryAttributesNode(CanonicalTreeParser.java:375)
    at org.eclipse.jgit.attributes.AttributesHandler.attributesNode(AttributesHandler.java:402)
    at org.eclipse.jgit.attributes.AttributesHandler.mergePerDirectoryEntryAttributes(AttributesHandler.java:232)
    at org.eclipse.jgit.attributes.AttributesHandler.getAttributes(AttributesHandler.java:144)
    at org.eclipse.jgit.treewalk.TreeWalk.getAttributes(TreeWalk.java:631)
    … 100 common frames omitted

16:13:27.652  The scanner engine did not complete successfully

how to trigger:

changing the .gitattributes file in a mono-repo from

\[path\]/\[file\].tar.gz filter=lfs diff=lfs merge=lfs -text
\[path\]/\[file\].deps.json filter=lfs diff=lfs merge=lfs -text
\[path\]/\[file\].dll filter=lfs diff=lfs merge=lfs -text
\[path\]/\[file\].xml filter=lfs diff=lfs merge=lfs -text

to:

\[path\]/\[file\].tar.gz filter=lfs diff=lfs merge=lfs -text
\[path\]/\[file\].deps.json filter=lfs diff=lfs merge=lfs -text
\[path\]/\[file\].dll filter=lfs diff=lfs merge=lfs -text
\[path\]/\[file\].xml filter=lfs diff=lfs merge=lfs -text
\[path\]/\*\* filter=lfs diff=lfs merge=lfs -text

FYI:

we had previously issues (crashes) on the same point in our CI/CD when we started using sparse checkout (this we’re working with multiple .NET solutions in a mono-repo), this has been solved by using the following config: sonar.scm.use.blame.algorithm=GIT_NATIVE_BLAME

even if we don’t sparse checkout the affected file, sonarscanner end fails :roll_eyes:. by changing that one single line, all sonar-analysis fails on all solutions in that mono-repo (30+)

Hi,

Could you help me understand what you’re doing with this line?

As I understand it, all your files are large files, managed in Large File Storage and not just select extensions?

If you’re purposely doing a sparse checkout, you’re not getting much benefit from the blame data anyway. Perhaps you should just disable it, either in the UI or with sonar.scm.disabled=true.

 
Ann

Hi Ann, i removed the real file name and forgot to add the file-name placeholder.

As we have a decent amount of binary data in our mono-repo and an intensive CI/CD, we definitely want sparse checkout to reduce the LFS bandwidth cost. Sonar is mostly used as a gate-keeper on our PR regarding required PR-metrics (quality gate). Once data is merged in main, we have other tooling to follow up on who did what.

We will follow up with your proposal to disable the sonar blame functionality