Missing blob jgit error with SonarCloud

We are using .NET C# and CircleCI. Our build pipeline worked without any issues for quite a long time.
However recently it started failing test step with a very weird error:

ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: org.eclipse.jgit.errors.MissingObjectException: Missing blob 14334bea9ef277dd309f82450e7317a1b204cedd
        at org.sonar.scm.git.blame.FileBlamer.waitForTasks(FileBlamer.java:238)
        at org.sonar.scm.git.blame.FileBlamer.blameWithFileDiffs(FileBlamer.java:213)
        at org.sonar.scm.git.blame.FileBlamer.blameParent(FileBlamer.java:133)
        at org.sonar.scm.git.blame.BlameGenerator.process(BlameGenerator.java:149)
        at org.sonar.scm.git.blame.BlameGenerator.generateBlame(BlameGenerator.java:127)
        at org.sonar.scm.git.blame.RepositoryBlameCommand.call(RepositoryBlameCommand.java:123)
        at org.sonar.scm.git.CompositeBlameCommand.blameWithFilesGitCommand(CompositeBlameCommand.java:187)
        at org.sonar.scm.git.CompositeBlameCommand.blame(CompositeBlameCommand.java:84)
        at org.sonar.scanner.scm.ScmPublisher.publish(ScmPublisher.java:76)
        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:164)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
        at org.sonar.scanner.bootstrap.ScannerContainer.doAfterStart(ScannerContainer.java:397)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
        at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:125)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
        at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:57)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:51)
        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
        at jdk.proxy1/jdk.proxy1.$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:126)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
        at org.sonarsource.scanner.cli.Main.main(Main.java:62)

This error is preventing us from using SonarCloud for the affected project. Only 1 project is affected, but on multiple branches. There are a lot of commits in this repository. Some branches just build without any issues.

This is the commands we are using for test + sonar:

        apt-get update && apt-get install libunwind8 libxml2 -y
        dotnet sonarscanner begin /k:"<<parameters.sonarscanner_project_key>>" /d:sonar.login=$SONAR_TOKEN /d:sonar.host.url=https://sonarcloud.io /o:"someorgname" /d:sonar.verbose=false /d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" /d:sonar.coverage.exclusions="**Tests*.cs,**/Migrations/*.cs,**/Startup.cs,**Program.cs,**Startup.cs"
        dotnet build
        dotnet test --logger "trx" --logger "console;verbosity=detailed" --collect "XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.SplitCoverage="True" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
        dotnet sonarscanner end /d:sonar.login=$SONAR_TOKEN

Can you please suggest what can cause this issue and some potential fix?
Thank you.

Hi @IvanSimanenka

Can you confirm you have blobless clone enabled in your pipeline?

1 Like

Hello Julien.
We are using standard circleci checkout command (CircleCI configuration reference) which does not support any parameters.
Modifying it to something custom is a very tricky thing.

Had a similar experience with CircleCI recently. Yes, their checkout command is now doing blob less clones.

See CircleCI Developer Hub - guitarrapc/git-shallow-clone for a workaround. If you use the checkout_advanced command you can control the number of commits or even simpler bring everything by just passing -v so that the default depth is overriden

1 Like

I am encountering a similar problem. Our pipeline was working just fine until a few weeks ago, but now we are getting the same error.

@Julien_HENRY we also use the checkout command in CircleCI which is confirmed to be a blobless clone as you stated. I posted in CircleCI letting them know that this is affect sonar here: [Product Update] Speeding up code checkout - #8 by brettjohnsen-sy - Build Environment - CircleCI Discuss

I don’t have CircleCI to test, but you can possibly use:

- checkout
- run: git fetch --no-filter --refetch

to fetch the entire history before running the SonarQube analysis.

I was able to fix the issue following the suggestion from Jose Javier Señaris.
This is how my checkout step looks now:

  - git-shallow-clone/checkout_advanced:
      clone_options: '--filter=blob:none'

With the usage of orb guitarrapc/git-shallow-clone.