SonarScanner error when executing in GitHub Actions

When I execute the following job in Github Action

name: Build
on:
  push:
    branches:
      - develop
  pull_request:
    types: [opened, synchronize, reopened]
jobs:
  sonarcloud:
    name: SonarCloud
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis
      - name: SonarCloud Scan
        uses: SonarSource/sonarcloud-github-action@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

I get the following error

INFO: SCM writing changed lines
INFO: SCM writing changed lines (done) | time=8ms
INFO: Analysis report generated in 228ms, dir size=212 KB
INFO: Analysis report compressed in 33ms, zip size=55 KB
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 51.164s
INFO: Final Memory: 46M/157M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: closed
    at okio.RealBufferedSource.select(RealBufferedSource.kt:218)
    at okhttp3.internal.Util.readBomAsCharset(Util.kt:265)
    at okhttp3.ResponseBody.string(ResponseBody.kt:187)
    at org.sonarqube.ws.client.OkHttpResponse.content(OkHttpResponse.java:67)
    at org.sonar.scanner.bootstrap.DefaultScannerWsClient.failIfUnauthorized(DefaultScannerWsClient.java:80)
    at org.sonar.scanner.bootstrap.DefaultScannerWsClient.call(DefaultScannerWsClient.java:61)
    at org.sonar.scanner.report.ReportPublisher.upload(ReportPublisher.java:222)
    at org.sonar.scanner.report.ReportPublisher.execute(ReportPublisher.java:159)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:420)
    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:130)
    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:58)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:52)
    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: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.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)
ERROR: 
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

Its the job fault or it is a Sonnar Scanner error? I saw people with the same problem talking about the response body been too long or not having enough space in the machine but the GitHub actions machine has 14GB of space

Hello @RobertoTeresa ,

Welcome to the community!

I can see that the error you encounter happens when the scanner attempts to upload an archive to SonarCloud (which we name “the analysis report”).

at org.sonar.scanner.report.ReportPublisher.upload(ReportPublisher.java:222)

I can see that the analysis report is very small

INFO: Analysis report generated in 228ms, dir size=212 KB
INFO: Analysis report compressed in 33ms, zip size=55 KB

So, both possible errors your mentioned are excluded.

I’m tempted to consider this could be a transient network error, either on SonarCloud side, on Gitbub actions side or anywhere in the middle.

Do you reproduce this error consistently?
Could you provide the whole extend of the Github action logs?