GHA change causing scans to fail

Template for a good new topic, formatted with Markdown:

  • ALM used: GitHub
  • CI system used : GHA
  • Scanner command used when applicable (private details masked): whatever is built in, we only set the token.
  • Languages of the repository: all
  • Only if the SonarCloud project is public, the URL: private repos
    • And if you need help with pull request decoration, then the URL to the PR too
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
17:43:31.541 ERROR Error during SonarScanner CLI execution
java.lang.IllegalStateException: Failed to get server version
	at org.sonarsource.scanner.lib.ScannerEngineBootstrapper.getServerVersion(ScannerEngineBootstrapper.java:194)
	at org.sonarsource.scanner.lib.ScannerEngineBootstrapper.bootstrap(ScannerEngineBootstrapper.java:117)
	at org.sonarsource.scanner.cli.Main.analyze(Main.java:75)
	at org.sonarsource.scanner.cli.Main.main(Main.java:63)
	Suppressed: java.lang.IllegalStateException: Call to URL [http://localhost:9000/api/v2/analysis/version] failed
		at org.sonarsource.scanner.lib.internal.http.ScannerHttpClient.callUrl(ScannerHttpClient.java:159)
		at org.sonarsource.scanner.lib.internal.http.ScannerHttpClient.callApi(ScannerHttpClient.java:126)
		at org.sonarsource.scanner.lib.internal.http.ScannerHttpClient.callRestApi(ScannerHttpClient.java:104)
		at org.sonarsource.scanner.lib.ScannerEngineBootstrapper.getServerVersion(ScannerEngineBootstrapper.java:189)
		... 3 common frames omitted
	Caused by: java.net.ConnectException: Failed to connect to localhost/[0:0:0:0:0:0:0:1]:9000
		at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:297)
		at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:207)
		at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226)
		at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
		at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
		at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
		at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
		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.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.kt:221)
		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.sonarsource.scanner.lib.internal.http.ScannerHttpClient.callUrl(ScannerHttpClient.java:157)
		... 6 common frames omitted
		Suppressed: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:9000
			... 25 common frames omitted
		Caused by: java.net.ConnectException: Connection refused
			at java.base/sun.nio.ch.Net.pollConnect(Native Method)
			at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672)
			at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:547)
			at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:602)
			at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
			at java.base/java.net.Socket.connect(Socket.java:633)
			at okhttp3.internal.platform.Platform.connectSocket(Platform.kt:128)
			at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:295)
			... 24 common frames omitted
	Caused by: java.net.ConnectException: Connection refused
		at java.base/sun.nio.ch.Net.pollConnect(Native Method)
		at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672)
		at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:547)
		at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:602)
		at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
		at java.base/java.net.Socket.connect(Socket.java:633)
		at okhttp3.internal.platform.Platform.connectSocket(Platform.kt:128)
		at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:295)
		... 24 common frames omitted
Caused by: java.lang.IllegalStateException: Call to URL [http://localhost:9000/api/server/version] failed
	at org.sonarsource.scanner.lib.internal.http.ScannerHttpClient.callUrl(ScannerHttpClient.java:159)
	at org.sonarsource.scanner.lib.internal.http.ScannerHttpClient.callApi(ScannerHttpClient.java:126)
	at org.sonarsource.scanner.lib.internal.http.ScannerHttpClient.callWebApi(ScannerHttpClient.java:112)
	at org.sonarsource.scanner.lib.ScannerEngineBootstrapper.getServerVersion(ScannerEngineBootstrapper.java:192)
	... 3 common frames omitted
Caused by: java.net.ConnectException: Failed to connect to localhost/[0:0:0:0:0:0:0:1]:9000
	at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:297)
	at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:207)
	at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226)
	at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
	at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
	at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
	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.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.kt:221)
	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.sonarsource.scanner.lib.internal.http.ScannerHttpClient.callUrl(ScannerHttpClient.java:157)
	... 6 common frames omitted
	Suppressed: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:9000
		... 25 common frames omitted
	Caused by: java.net.ConnectException: Connection refused
		at java.base/sun.nio.ch.Net.pollConnect(Native Method)
		at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672)
		at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:547)
		at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:602)
		at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
		at java.base/java.net.Socket.connect(Socket.java:633)
		at okhttp3.internal.platform.Platform.connectSocket(Platform.kt:128)
		at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:295)
		... 24 common frames omitted
Caused by: java.net.ConnectException: Connection refused
	at java.base/sun.nio.ch.Net.pollConnect(Native Method)
	at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672)
	at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:547)
	at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:602)
	at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
	at java.base/java.net.Socket.connect(Socket.java:633)
	at okhttp3.internal.platform.Platform.connectSocket(Platform.kt:128)
	at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:295)
	... 24 common frames omitted
  • Steps to reproduce - Use the default GHA sonarcloud scanner with no url specified for a sonarcloud url
  • Potential workaround - Add SONARCLOUD_URL as an env var in the workflow

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!
The most recent change removes this default setting of the SONARCLOUD_URL. No docs were updated that this behavior was changing.

Hi @Gris13

Sorry for the inconvenience. For now, we have retired the SONARCLOUD_URL to control the sonar.host.url value as it is not aligned with the scanner setup. It sets the -Dsonar.scanner.sonarcloudUrl, which is not meant to override sonar.host.url setup.
We do set it by default for you if you do not specify sonar.host.url. So please check your sonar.properties or any configuration that may set the sonar.host.url property and either set it to https://sonarcloud.io or just remove that setup, and we will take care of the defaults.

We will make sure to clarify this in the documentation if it is not done yet.

thanks
Csaba

Hi @Gris13

Small clarification you can achieve the same setup if you remove the sonar.host.url setup in your config and only set the SONARCLOUD_URL. It will work the same way if you desire to override the default host for some tests.
Just to make sure I am clear sonar.host.url is overriding the host URL.

Hope that helps.

thanks
Csaba

Thanks for the clarification.
It does appear that most of our failures are due to having the sonar.host.url set in our sonar.properties files. Ill let other devs know to update and remove this to resolve it and then unpin our actions.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.