Sonarlint connection to SonarQube via VSCODE No storage for connection MalformedJsonException

Hello,

-I am trying to connect sonarlint on VS code to my sonarqube server.
When I run the ‘Update all project bindings’ I get the following errors:

[Error - 11:53:09.669] Error updating the local storage of the connection with id '<default>'
[Error - 11:53:09.673] org.sonarsource.sonarlint.shaded.com.google.gson.JsonSyntaxException: org.sonarsource.sonarlint.shaded.com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 12 path $
    at org.sonarsource.sonarlint.shaded.com.google.gson.JsonParser.parseReader(JsonParser.java:66)
    at org.sonarsource.sonarlint.shaded.com.google.gson.JsonParser.parseString(JsonParser.java:47)
    at org.sonarsource.sonarlint.core.serverapi.ServerApiHelper.tryParseAsJsonError(ServerApiHelper.java:151)
    at org.sonarsource.sonarlint.core.serverapi.ServerApiHelper.handleError(ServerApiHelper.java:135)
    at org.sonarsource.sonarlint.core.serverapi.ServerApiHelper.lambda$getAsync$0(ServerApiHelper.java:81)
    at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)
    at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
    at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2073)
    at org.sonarsource.sonarlint.ls.http.ApacheHttpClient$CompletableFutureWrapper.completed(ApacheHttpClient.java:120)
    at org.sonarsource.sonarlint.ls.http.ApacheHttpClient$CompletableFutureWrapper.completed(ApacheHttpClient.java:109)
    at org.apache.hc.core5.concurrent.BasicFuture.completed(BasicFuture.java:123)
    at org.apache.hc.core5.concurrent.ComplexFuture.completed(ComplexFuture.java:79)
    at org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient$1$3$1.completed(InternalAbstractHttpAsyncClient.java:297)
    at org.apache.hc.core5.http.nio.support.AbstractAsyncResponseConsumer$2.completed(AbstractAsyncResponseConsumer.java:108)
    at org.apache.hc.core5.http.nio.entity.AbstractBinAsyncEntityConsumer.completed(AbstractBinAsyncEntityConsumer.java:84)
    at org.apache.hc.core5.http.nio.entity.AbstractBinDataConsumer.streamEnd(AbstractBinDataConsumer.java:81)
    at org.apache.hc.core5.http.nio.support.AbstractAsyncResponseConsumer.streamEnd(AbstractAsyncResponseConsumer.java:149)
    at org.apache.hc.client5.http.impl.async.HttpAsyncMainClientExec$1.streamEnd(HttpAsyncMainClientExec.java:233)
    at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamHandler.dataEnd(ClientHttp1StreamHandler.java:280)
    at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamDuplexer.dataEnd(ClientHttp1StreamDuplexer.java:366)
    at org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.onInput(AbstractHttp1StreamDuplexer.java:325)
    at org.apache.hc.core5.http.impl.nio.AbstractHttp1IOEventHandler.inputReady(AbstractHttp1IOEventHandler.java:64)
    at org.apache.hc.core5.http.impl.nio.ClientHttp1IOEventHandler.inputReady(ClientHttp1IOEventHandler.java:39)
    at org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:131)
    at org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:51)
    at org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:178)
    at org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:127)
    at org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:85)
    at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44)
    at java.base/java.lang.Thread.run(Thread.java:834)

-I am using VSCode version 1.62.3 and SonarLint version 3.1.0
The project is Apex language based so establishing the connection to the server is a necessity.

-I already added

                "sonarlint.connectedMode.connections.sonarqube":[
                 {
                  "serverUrl": "http://sonarqube.mut....",
                  "token": "59382a2d82..."
                 }
                ]

to user settings
and

      "sonarlint.connectedMode.project":{
       "projectKey": "CLI-al..."
        }

to my project workspace.

I also added the sonar server certificate to my local java cacerts.

I also get the following response :
{"id":"FCBD16EB-AWWoluJDIq3hYDfqE6EW","version":"8.9.1.44547","status":"UP"}
When I access myserver/api/system/status on the web.

Any suggestion?

Hello, welcome to the community! And thanks for your question.

Are you using a proxy to reach your SonarQube server?

We got similar reports in the past, where the HTTP client used to initialize connected mode tries to parse as JSON a response that is definitely not JSON - usually, it’s a HTML page with the proxy authentication error.

It can also happen if the SonarQube server is unreachable (e.g during a system update) and behind a reverse proxy: the reverse proxy answers with a 503 that is usually not in JSON.

Also, I notice that your server URL is in plain HTTP; since you mention that you added the “sonar server certificate” to your Java trusted certificates, I assume that this should be HTTPS?

Hello and thank you for your fast response !

Indeed, we are using a proxy server but the problem was solved after I replaced the http with https (my bad).

Thanks again for your help and have a sonarful day :slight_smile:

2 Likes

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