SonarScanner fails to send a report if faulty file is analysed

Hi,

After upgrading SonarQube from 8.x to version 9.1 (but I confirmed that this is also happening on 9.2.4), one of our projects started failing when trying to send analysis:

09:13:40.733 INFO: Analysis report generated in 76ms, dir size=195.6 kB
09:13:40.760 INFO: Analysis report compressed in 27ms, zip size=30.5 kB
09:13:40.760 INFO: Analysis report generated in /Users/andrzejkasiewicz/betty_checkout_msbimporter_single/.scannerwork/scanner-report
09:13:40.760 DEBUG: Upload report
09:14:40.787 INFO: ------------------------------------------------------------------------
09:14:40.787 INFO: EXECUTION FAILURE
09:14:40.787 INFO: ------------------------------------------------------------------------
09:14:40.788 INFO: Total time: 1:15.584s
09:14:40.856 INFO: Final Memory: 45M/164M
09:14:40.856 INFO: ------------------------------------------------------------------------
09:14:40.856 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Failed to upload report: Fail to request url: https://sonarqube.****.net/api/ce/submit?projectKey=oma_msbimporter_test&projectName=oma_msbimporter_test&characteristic=branch%3Dmaster&characteristic=branchType%3DBRANCH
	at org.sonar.scanner.report.ReportPublisher.upload(ReportPublisher.java:207)
	at org.sonar.scanner.report.ReportPublisher.execute(ReportPublisher.java:142)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:355)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
	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(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	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: Fail to request url: https://sonarqube.****.net/api/ce/submit?projectKey=oma_msbimporter_test&projectName=oma_msbimporter_test&characteristic=branch%3Dmaster&characteristic=branchType%3DBRANCH
	at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:205)
	at org.sonarqube.ws.client.HttpConnector.post(HttpConnector.java:155)
	at org.sonarqube.ws.client.HttpConnector.call(HttpConnector.java:114)
	at org.sonar.scanner.bootstrap.DefaultScannerWsClient.call(DefaultScannerWsClient.java:73)
	at org.sonar.scanner.report.ReportPublisher.upload(ReportPublisher.java:205)
	... 21 more
Caused by: java.net.SocketTimeoutException: timeout
	at okio.SocketAsyncTimeout.newTimeoutException(JvmOkio.kt:143)
	at okio.AsyncTimeout.access$newTimeoutException(AsyncTimeout.kt:162)
	at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:335)
	at okio.RealBufferedSource.indexOf(RealBufferedSource.kt:427)
	at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:320)
	at okhttp3.internal.http1.HeadersReader.readLine(HeadersReader.kt:29)
	at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:178)
	at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:106)
	at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:79)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at org.sonarqube.ws.client.OkHttpClientBuilder.addHeaders(OkHttpClientBuilder.java:222)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
	at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
	at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:203)
	... 25 more
Caused by: java.net.SocketTimeoutException: Read timed out
	at java.base/java.net.SocketInputStream.socketRead0(Native Method)
	at java.base/java.net.SocketInputStream.socketRead(Unknown Source)
	at java.base/java.net.SocketInputStream.read(Unknown Source)
	at java.base/java.net.SocketInputStream.read(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketInputRecord.read(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketImpl.readApplicationRecord(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(Unknown Source)
	at okio.InputStreamSource.read(JvmOkio.kt:90)
	at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:129)
	... 45 more

This seems like a problem with network, but after investigating we found out that the problem is with one of the files in the repository. Any modification of this file (eg. adding empty line in the middle) and analysis is successfully sent to server. Unfortunately for legal reasons I’m not able to provide this file. If that changes anything the file is written in Java.

The same is happening on both gradle plugin and standalone sonar-scanner.

Please let me know if I can give any more details that could help with finding the reason of this.

Hi,

Can you provide any metadata about the file, e.g. size?

Also, is there a typo here (emphasis mine)?

And one more question: can you characterize the size of the report upload with/without changes to that file?

 
Ann

Hi,

Thanks for the reply!

The problem stops occurring after making any modification to the faulty file. So of course I was able resolve the issue easily, but still there seems to be a bug in sonar scanner that might affect other repositories in the future.

Metadata of the file:

_kMDItemDisplayNameWithExtensions      = "PutUpdateMposResponsePact.java"
kMDItemContentCreationDate             = 2022-01-05 08:18:37 +0000
kMDItemContentCreationDate_Ranking     = 2022-01-05 00:00:00 +0000
kMDItemContentModificationDate         = 2022-01-10 08:03:23 +0000
kMDItemContentModificationDate_Ranking = 2022-01-10 00:00:00 +0000
kMDItemContentType                     = "com.sun.java-source"
kMDItemContentTypeTree                 = (
    "com.sun.java-source",
    "public.source-code",
    "public.plain-text",
    "public.text",
    "public.data",
    "public.item",
    "public.content"
)
kMDItemDateAdded                       = 2022-01-05 08:18:37 +0000
kMDItemDateAdded_Ranking               = 2022-01-05 00:00:00 +0000
kMDItemDisplayName                     = "PutUpdateMposResponsePact.java"
kMDItemDocumentIdentifier              = 0
kMDItemFSContentChangeDate             = 2022-01-10 08:03:23 +0000
kMDItemFSCreationDate                  = 2022-01-05 08:18:37 +0000
kMDItemFSCreatorCode                   = ""
kMDItemFSFinderFlags                   = 0
kMDItemFSHasCustomIcon                 = (null)
kMDItemFSInvisible                     = 0
kMDItemFSIsExtensionHidden             = 0
kMDItemFSIsStationery                  = (null)
kMDItemFSLabel                         = 0
kMDItemFSName                          = "PutUpdateMposResponsePact.java"
kMDItemFSNodeCount                     = (null)
kMDItemFSOwnerGroupID                  = 20
kMDItemFSOwnerUserID                   = 501
kMDItemFSSize                          = 3657
kMDItemFSTypeCode                      = ""
kMDItemInterestingDate_Ranking         = 2022-01-10 00:00:00 +0000
kMDItemKind                            = "Java source code"
kMDItemLogicalSize                     = 3657
kMDItemPhysicalSize                    = 4096

I stripped whole project to just this file and its compiled version. Before the modification of the file:

09:05:42.391 INFO: Analysis report generated in 130ms, dir size=195.6 kB
09:05:42.421 INFO: Analysis report compressed in 30ms, zip size=30.5 kB
09:05:42.422 INFO: Analysis report generated in /Users/andrzejkasiewicz/betty_checkout_msbimporter_single/.scannerwork/scanner-report
09:05:42.422 DEBUG: Upload report
09:06:42.447 INFO: ------------------------------------------------------------------------
09:06:42.447 INFO: EXECUTION FAILURE
09:06:42.447 INFO: ------------------------------------------------------------------------
09:06:42.447 INFO: Total time: 1:14.046s
09:06:42.531 INFO: Final Memory: 45M/164M
09:06:42.531 INFO: ------------------------------------------------------------------------
09:06:42.532 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Failed to upload report: Fail to request url: https://sonarqube.****.net/api/ce/submit?projectKey=oma_msbimporter_test&projectName=oma_msbimporter_test&characteristic=branch%3Dmaster&characteristic=branchType%3DBRANCH
(...)

After adding additional empty line at the end of the file:

09:07:53.766 INFO: Analysis report generated in 125ms, dir size=195.6 kB
09:07:53.793 INFO: Analysis report compressed in 27ms, zip size=30.5 kB
09:07:53.794 INFO: Analysis report generated in /Users/andrzejkasiewicz/betty_checkout_msbimporter_single/.scannerwork/scanner-report
09:07:53.794 DEBUG: Upload report
09:07:53.914 DEBUG: POST 200 https://sonarqube.****.net/api/ce/submit?projectKey=oma_msbimporter_test&projectName=oma_msbimporter_test&characteristic=branch%3Dmaster&characteristic=branchType%3DBRANCH | time=119ms
09:07:53.926 INFO: Analysis report uploaded in 128ms
09:07:53.927 DEBUG: Report metadata written to /Users/andrzejkasiewicz/betty_checkout_msbimporter_single/.scannerwork/report-task.txt
09:07:53.927 INFO: ANALYSIS SUCCESSFUL, you can browse https://sonarqube.****.net/dashboard?id=oma_msbimporter_test&branch=master
09:07:53.927 INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
09:07:53.927 INFO: More about the report processing at https://sonarqube.****.net/api/ce/task?id=AX5DB4eAoboRQtrszqkB
09:07:53.931 DEBUG: Post-jobs : Forbidden Configuration Breaker -> Quality Gate Breaker
09:07:53.931 INFO: Executing post-job 'Forbidden Configuration Breaker'
09:07:53.931 INFO: Executing post-job 'Quality Gate Breaker'
09:07:53.931 DEBUG: QualityGateBreaker is disabled (sonar.buildbreaker.skip = true)
09:07:53.933 INFO: Analysis total time: 10.087 s
09:07:53.936 INFO: ------------------------------------------------------------------------
09:07:53.936 INFO: EXECUTION SUCCESS
09:07:53.937 INFO: ------------------------------------------------------------------------
09:07:53.937 INFO: Total time: 12.144s
09:07:54.017 INFO: Final Memory: 45M/160M
09:07:54.017 INFO: ------------------------------------------------------------------------

Hi,

I really appreciate your following up with this data. I’m in over my head & have flagged this thread for more expert attention. Hopefully they’ll get here soon.

 
Ann

Hi,
That’s a strange one! I really can’t see a path to get to the root cause of it.

Do you have any relevant logs on the server side?

Andrzej_Kasiewicz How were you able to identify the faulty file?
I’ve started having the same issue just recently.

Is there a proper solution from SonarQube for this issue? I am also facing similar issue from last week.

Hi,
Please share more details about the error you’re facing. Ideally, share a simple reproducer or at least the file causing it, assuming it’s the same problem as the OP. Honestly right now there isn’t enough information for us to get to the root cause of it.

hey guys heaving the same issue here. @Andrzej_Kasiewicz how did you identify the problematic file?

@Nikola_Dacic do you have a reproducer?

Hey @dmeneses found what the issue was. Its our nginx ingress setup on k8s. Needed to increasse proxy body size on it.

Report never reached sq server.

Scanner didn’t generate any log error though. No http error code 403 or anything like that.

Ok, thanks.

Hey, I am also facing the same error. Can someone please have a look and help us.
14:32:43.732 ERROR: Error during SonarScanner execution

java.lang.IllegalStateException: Failed to upload report: Fail to request url: https://some url/api/ce/submit?projectKey=TB&projectName=TB
at org.sonar.scanner.report.ReportPublisher.upload(ReportPublisher.java:207)
at org.sonar.scanner.report.ReportPublisher.execute(ReportPublisher.java:142)
at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:365)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:134)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
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(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
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: Fail to request url: https://some url/api/ce/submit?projectKey=TB&projectName=TB
at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:205)
at org.sonarqube.ws.client.HttpConnector.post(HttpConnector.java:155)
at org.sonarqube.ws.client.HttpConnector.call(HttpConnector.java:114)
at org.sonar.scanner.bootstrap.DefaultScannerWsClient.call(DefaultScannerWsClient.java:73)
at org.sonar.scanner.report.ReportPublisher.upload(ReportPublisher.java:205)
… 21 more
Caused by: okhttp3.internal.http2.StreamResetException: stream was reset: NO_ERROR
at okhttp3.internal.http2.Http2Stream.checkOutNotClosed$okhttp(Http2Stream.kt:646)
at okhttp3.internal.http2.Http2Stream$FramingSink.emitFrame(Http2Stream.kt:557)
at okhttp3.internal.http2.Http2Stream$FramingSink.write(Http2Stream.kt:532)
at okio.ForwardingSink.write(ForwardingSink.kt:29)
at okhttp3.internal.connection.Exchange$RequestBodySink.write(Exchange.kt:218)
at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.kt:255)
at okio.RealBufferedSink.writeAll(RealBufferedSink.kt:194)
at okhttp3.RequestBody$Companion$asRequestBody$1.writeTo(RequestBody.kt:167)
at okhttp3.MultipartBody.writeOrCountBytes(MultipartBody.kt:157)

Looks like you’re experiencing a connection error. Did you check if it’s related to a proxy sitting between the scanner and SonarQube?

Hey, other projects are getting created in sonarqube. Only the issue with few projects and getting same kind of error. Please help.

Hi,

The fact that the problem is intermittent is even more indication - not less - that it’s likely your proxy blocking the upload of the analysis report because the payload has crossed some arbitrary size limit. You should talk to your network folks.

 
Ann

Hey,
From the server end we are getting below logs – unable to understand whether its related to project:

2022.12.15 17:37:47 ERROR web[AYPKwKv7RlQU02f7AW9M][o.s.s.p.UpdateCenterClient] Fail to connect to update center
org.sonar.api.utils.SonarException: Fail to download: https://update.sonarsource.org/update-center.properties (no proxy)
at org.sonar.core.util.DefaultHttpDownloader.failToDownload(DefaultHttpDownloader.java:157)

Hi,

That’s unrelated.

 
Ann

okay. Thankyou Ann.

Hello, Can someone help if we can download Analysis Report using cicd pipeline.