Sonarlint connected mode error in VS Code

When I run “Update Sonarlint binding to SonarQube/Sonarcloud” in my command pallete, after setting everything up, I get a message “sonarlint invalid binding: The specified serverId does not exist”.

settings.json contains:
“sonarlint.connectedMode.servers”: [
{
“serverId”: “A7EE8CF2-AWDcFNr3S42ZL2FICAak”,
“serverUrl”: “<my_url>”,
“token”: “<my_token>”
}

and I confirmed that the serverId is identical to what I see in Administration -> System Server ID field. In fact, I copied and pasted it there.

VS Code version: 1.33.0
SonarLint version: 1.6.0

Can someone help?

1 Like

Hi @innanill

The serverId in this context is not what you think. The binding configuration in VSCode is splitted in 2 parts. One part are credentials/global details that are probably the same for all projects of a given user. Those settings should be stored in user settings. For example in my case I have:

"sonarlint.connectedMode.servers": [
    { "serverId": "next", "serverUrl": "https://next.sonarqube.com/sonarqube", "token": "xxxxxx" },
    { "serverId": "sonarcloud", "organizationKey": "julienhenrysonarsource-bitbucket", "serverUrl": "https://sonarcloud.io", "token": "yyyyyy" }
],

And then for every project, you will configure the server + projectKey it should be bound to. Since it is project specific, you should store that at workspace level. Like:

"sonarlint.connectedMode.project": {
    "serverId": "sonarcloud", // Connection defined in sonarlint.connectedMode.servers
    "projectKey": "sample-ts-henryju" // Project key in SonarQube/SonarCloud
},

You can see that the “serverId” in “sonarlint.connectedMode.project” should match one defined in “sonarlint.connectedMode.servers”. But except from that, you can choose any identifier.

2 Likes

@Julien_HENRY, it looks like that worked! Thanks!