Failed to authenticate to sonarqube server using Proxy and Token. IntelliJ plugin

Hi All I’m using IntelliJ 2021.1.3 and I have installed sonarLint IntelliJ 5.0.1.33703.

In the IntelliJ interface, If I go to Tools > SonarLint and try to configure a sonarqube connection , I’m able to enter the connection name, the sonarqube URL and then click on next, however when I enter the token and press next I’m displayed with a weird error which says:

Failed to connect to the server. Please check the configuration. Error: org.sonarsource.sonarlint.shaded.com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 12 path $

The sonarLint log queue prints the following message:

Connection test failed
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:129)
at org.sonarsource.sonarlint.core.serverapi.ServerApiHelper.handleError(ServerApiHelper.java:113)
at org.sonarsource.sonarlint.core.serverapi.ServerApiHelper.get(ServerApiHelper.java:71)
at org.sonarsource.sonarlint.core.container.connected.validate.ServerVersionAndStatusChecker.lambda$fetchServerInfos$0(ServerVersionAndStatusChecker.java:97)
at org.sonarsource.sonarlint.core.serverapi.ServerApiHelper.processTimed(ServerApiHelper.java:198)
at org.sonarsource.sonarlint.core.container.connected.validate.ServerVersionAndStatusChecker.fetchServerInfos(ServerVersionAndStatusChecker.java:96)
at org.sonarsource.sonarlint.core.container.connected.validate.ServerVersionAndStatusChecker.checkVersionAndStatus(ServerVersionAndStatusChecker.java:60)
at org.sonarsource.sonarlint.core.container.connected.validate.ServerVersionAndStatusChecker.checkVersionAndStatus(ServerVersionAndStatusChecker.java:50)
at org.sonarsource.sonarlint.core.client.api.connected.ConnectionValidator.validateConnection(ConnectionValidator.java:44)
at org.sonarlint.intellij.tasks.ConnectionTestTask.run(ConnectionTestTask.java:50)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:998)
at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.java:545)
at com.intellij.openapi.progress.impl.ProgressRunner.lambda$new$0(ProgressRunner.java:78)
at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:228)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:178)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:688)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:634)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:64)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:165)
at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:228)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: 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.stream.JsonReader.syntaxError(JsonReader.java:1564)
at org.sonarsource.sonarlint.shaded.com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1405)
at org.sonarsource.sonarlint.shaded.com.google.gson.stream.JsonReader.doPeek(JsonReader.java:543)
at org.sonarsource.sonarlint.shaded.com.google.gson.stream.JsonReader.peek(JsonReader.java:426)
at org.sonarsource.sonarlint.shaded.com.google.gson.JsonParser.parseReader(JsonParser.java:61)

I’m not sure if I’m missing some step. I would really appreciate if you could help me with this issue. Thanks.

Hello Leonardo,

Welcome to the community and thanks for raising this issue.

What version of SonarQube are you trying to connect to ? FYI we only support connection to a Sonarqube 7.9+ instance.

Could it be possible that the SonarQube instance was down when you tried ? My guess is that your SonarQube returned an error message that couldn’t be parsed. Could you try to access <your-sonarqube-instance>/api/system/status from your browser while authenticated and send us what is returned ?

Thanks