SonarLint fails to connect to Sonarqube

Please provide

  • Operating system: Windows 10 PRO
  • SonarLint plugin version: 6.12.0.59751
  • Programming language you’re coding in: C#
  • Is connected mode used:
    • Connected to SonarCloud or SonarQube (and which version): sonarQube 9.8.0.63668

And a thorough description of the problem / question:

Hello,

I try to connect to my Sonarqube server and I can’t although always I’ve always been able to connect with no problem.
I get this log in visual studio:

[ThreadId 1] Connecting to SonarQube server: https://mysonarqubeserver:8090/
[ThreadId 1] Connecting to SonarQube server: Validating credentials
[ThreadId 24] Connecting to ' https://mysonarqubeserver:8090/.
[ThreadId 24] [DEBUG] IsConnected is False.
[ThreadId 24] [DEBUG] Selected SonarQube request factory
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V2_10.GetPluginsRequest for 2.1
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V2_10.GetProjectsRequest for 2.1
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V2_10.GetVersionRequest for 2.1
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V2_60.GetPropertiesRequest for 2.6
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V3_30.ValidateCredentialsRequest for 3.3
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V5_00.GetSourceCodeRequest for 5.0
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V5_10.GetIssuesRequest for 5.1
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V5_10.GetLanguagesRequest for 5.1
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V5_20.GetQualityProfileChangeLogRequest for 5.2
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V5_20.GetQualityProfilesRequest for 5.2
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V5_20.GetRoslynExportProfileRequest for 5.2
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V5_40.GetModulesRequest for 5.4
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V5_50.GetRulesRequest for 5.5
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V5_50.DownloadStaticFile for 5.5
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V6_20.GetOrganizationsRequest for 6.2
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V6_20.GetProjectsRequest for 6.2
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V6_30.GetPluginsRequest for 6.3
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V6_30.GetPropertiesRequest for 6.3
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V6_50.GetQualityProfileChangeLogRequest for 6.5
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V6_50.GetQualityProfilesRequest for 6.5
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V6_60.GetNotificationsRequest for 6.6
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V6_60.GetRoslynExportProfileRequest for 6.6
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V6_60.GetProjectBranchesRequest for 6.6
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V7_00.GetOrganizationsRequest for 7.0
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V7_20.GetIssuesRequestWrapper for 7.2
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V8_6.GetHotspotRequest for 8.6
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V8_6.GetTaintVulnerabilitiesRequest for 8.6
[ThreadId 24] [DEBUG] Registered SonarQube.Client.Api.V7_20.GetExclusionsRequest for 7.2
[ThreadId 24] [DEBUG] Getting the version of SonarQube...
[ThreadId 24] [DEBUG] Looking up implementation of 'IGetVersionRequest' for version '' on thread '24'
[ThreadId 24] [DEBUG] Created request of type 'SonarQube.Client.Api.V2_10.GetVersionRequest'.
[ThreadId 24] [DEBUG] Sending Http request:
[ThreadId 24] [DEBUG] Method: GET, RequestUri: 'api/server/version', Version: 1.1, Content: <null>, Headers:
{
}
[ThreadId 16] [DEBUG] Response with HTTP status code 'OK' received.
[ThreadId 16] [DEBUG] 9.8.0.63668
[ThreadId 16] Connected to SonarQube '9.8.0.63668'.
[ThreadId 16] [DEBUG] Validating the credentials...
[ThreadId 16] [DEBUG] Looking up implementation of 'IValidateCredentialsRequest' for version '' on thread '16'
[ThreadId 16] [DEBUG] Created request of type 'SonarQube.Client.Api.V3_30.ValidateCredentialsRequest'.
[ThreadId 16] [DEBUG] Sending Http request:
[ThreadId 16] [DEBUG] Method: GET, RequestUri: 'api/authentication/validate', Version: 1.1, Content: <null>, Headers:
{
}
[ThreadId 35] [DEBUG] Response with HTTP status code 'OK' received.
[ThreadId 35] [DEBUG] {"valid":true}
[ThreadId 35] [DEBUG] Credentials accepted.
[ThreadId 1] Connecting to SonarQube server: Detecting server plugins
[ThreadId 35] [DEBUG] Looking up implementation of 'IGetPluginsRequest' for version '9.8.0.63668' on thread '35'
[ThreadId 35] [DEBUG] Created request of type 'SonarQube.Client.Api.V6_30.GetPluginsRequest'.
[ThreadId 35] [DEBUG] Sending Http request:
[ThreadId 35] [DEBUG] Method: GET, RequestUri: 'api/plugins/installed', Version: 1.1, Content: <null>, Headers:
{
}
[ThreadId 16] [DEBUG] Response with HTTP status code 'Forbidden' received.
[ThreadId 16] SonarQube request failed: El código de estado de la respuesta no indica un resultado correcto: 403 ( ). 
[ThreadId 1] Connecting to SonarQube server: Failed
[ThreadId 16] Disconnecting...
[ThreadId 16] [DEBUG] Current state before disconnecting is 'Connected'.

I never introduced credentials in “connect to a Sonarqube server” window, only the URL of my sonarQube server.
I could see in the log, there is a problem when detecting server plugins but I can’t understand where is the problem.

Thank you very much!

Hi @pemola.

  1. do you now if the configuration of the SonarQube server has changed e.g. is anonymous access now disallowed?

  2. have you previously managed to connect successfully from that local machine, or was it from another machine?

  3. Can successfully bind a new solution to a project on the same SonarQube server? (i.e. create a new dummy solution, and attempt to bind it, making sure to provide credentials)

Hello

  1. We don’t change the configuration of Sonarqube Server. Force user authentication is disabled.
    autentication sonarqube
  2. Yes, I use to connect to Sonarqube from the same machine.
  3. I try to create the default web api project (withouth new code) and get the same error.

I have Visual studio 2022 and visual studio 2019 installed in the machine where I test the sonarqube connection, but VS2022 haven’t sonarlint extension.

Thank you very much for your reply. :slight_smile:

@pemola I suspect that SonarLint is making a call to a web API that requires the user to be authenticated.

Can you check the access.log file of your SonarQube server to see if that has more information about the 403 response please?

Hi,

Yes, I could see in access.log that this API seems to return 401:

0:0:0:0:0:0:0:1 - - [28/feb./2023:09:18:31 +0100] "GET /api/developers/search_events?projects=ejemplo&from=2023-02-27T09%3A09%3A30%2B0100 HTTP/1.1" 401 49 "-" "SonarLint Visual Studio/6.13.0.62767" "AYZeaeeOHBcLsxFzALpg"

And another one, return 403:

0:0:0:0:0:0:0:1 - - [28/feb./2023:09:18:16 +0100] "GET /api/plugins/installed HTTP/1.1" 403 46 "-" "SonarLint Visual Studio/6.13.0.62767" "AYZeaeeOHBcLsxFzALpc"

Rest of APIs seems to works fine:

0:0:0:0:0:0:0:1 - - [28/feb./2023:09:18:22 +0100] "GET /api/server/version HTTP/1.1" 200 - "-" "SonarLint Visual Studio/6.13.0.62767" "AYZeaeeOHBcLsxFzALpd"
0:0:0:0:0:0:0:1 - - [28/feb./2023:09:18:22 +0100] "GET /api/authentication/validate HTTP/1.1" 200 14 "-" "SonarLint Visual Studio/6.13.0.62767" "AYZeaeeOHBcLsxFzALpe"

Is this a bug or a new feature in that API which needs authentication?