Statuscode 400 - Duplicate key while retrieving projects


It is no longer possible for us to see all our projects within SonarCloud. When we use the ‘Show More’ Button and reach beyond 150 projects. The button dies.

Edge Developer tools shows us a 400 error:

When we try to get an overview using the API, some extra info appears:

$token = 'SonarcloudPATToken'
$url = "<org>&ps=130";

$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:" -f $token)))
$componentData = Invoke-RestMethod -Uri $url -Method 'GET' -Headers @{Authorization = ("Basic {0}" -f $base64AuthInfo) }
  "errors": [
      "msg": "Duplicate key AYdWwJ0NefCAB3PD2UdP"

There is now way for us to figure out which projects are causing this issue, because we keep bumping into this 400 statuscode.

What is the best way to resolve this issue?

Hello @PeterBa,

Welcome to the community!

Thank you for bringing this behavior to our attention. It appears to be a bug that requires fixing, so I have created an internal ticket to address it.

In order to gather some more information that could help us resolve it, if I understood correctly, you are not facing this issue constantly. Still, you cannot identify the project that causes it when it happens. Am I correct?

Hello @juanmanuel.moratilla ,

The issue has been resolved with some luck. One of our developers indicated that their Sonar project was behaving strangely. The Sonar Azure Devops extension claimed the project did not exist and it was not to be found in the Sonar UI.

I managed to delete this particular project using the bulk_delete api (SonarCloud). The regular delete for one project did not work. This API call also generated the same 400 error.

After deleting this project, all sonarcloud issues were resolved. The developer recreated the project and the problem did not return.

Some extra information that might help with the bugfixing:

The following URL gave the 400 statuscode:<org>&ps=130

Changing the PS to a number below 130 would result in in a 200 statuscode.
The Sonar website showed the same behaviour. It loads 50 projects at the time, so we could see 100 projects, but trying to get the next 50 project would give the 400 statuscode.

If possible i can send you a private message with the organization name, project ID and the date/time of the fix. With that info you might be able to backtrack what caused the issue?