400 error when searching/listing projects

Hi all,
Since last Friday (10th May 2024) my org has been experiencing an issue when searching for existing projects that have already been added.

We have 127 projects but when we try to filter that list down by searching for a a known project it returns an empty list. In the browser console this search activity returns a 400 response from

https://sonarcloud.io/api/components/search_projects?boostNewProjects=true&ps=50&facets=reliability_rating%2Csecurity_rating%2Csecurity_review_rating%2Csqale_rating%2Ccoverage%2Cduplicated_lines_density%2Cncloc%2Calert_status%2Clanguages%2Ctags&f=analysisDate%2CleakPeriodDate&organization=MyOrg&filter=query+%3D+"Example.Project"

This is also affecting our pipeline runs via CICD. For example the below project exists, I can’t search for it but I know it exists as when I try to add a new project I can see that it has already been added to my organisation.

##[error]ERROR: Error during SonarScanner execution

ERROR: Could not find a default branch for project with key ‘MyOrg.Examle.Project’. Make sure project exists.

ERROR:

ERROR: Error during SonarScanner execution

ERROR: Could not find a default branch for project with key ‘MyOrg.Examle.Project’. Make sure project exists.

ERROR:

Not really sure how I can move forward with this as we have had to disable sonarcloud in some CICD projects because of this issue. It doesn’t appear to be end user related as I have been able to confirm this behavior with 2 other colleagues.

Is there an ongoing issue with sonarcloud backend API? As all things seem to be pointing to that 400 error we get when searching for a project. Yet there are no outages reported on the status page.

The organisation is on a paid plan and all projects are private. Could really do with some help to get this back working again.

Regards

Do SonarCloud employees read these forums as I am on a paid plan and currently SonarCloud is unusable due to this 400 error with their backend api.

Any idea how I can report this issue with SonarCloud? Is there any functionality to be able to raise a bug?

Hello @15307 Mark,

I understand that you are getting a 400 error when trying to search a project (filter=query+%3D+“Example.Project”) that is under one of your organizations (organization=MyOrg) using the search_projects API.

Please note that the organization key must follow the following pattern (as described in the API and in the UI when creating an organization manually):

Organization key must start with a lowercase letter or number, followed by lowercase letters, numbers or hyphens, and must end with a letter or number. Maximum length: 255 characters.

That being said, I have been running some tests at my end, and I got the same response as you when trying to find the projects under my organization filtering by the organization name instead of using the key (or using the wrong key of my organization or using upper case for the organization key):

https://sonarcloud.io/api/components/search_projects?organization=MyOrg
Response: 404

vs

https://sonarcloud.io/api/components/search_projects?organization=myorg
Response: 200

So, can you please try using the organization key (which should not contain upper case) in the API call?

Thank you for the reply. The code snippets I added were examples as I didn’t want to post sensitive data about my org.

My org key is lower case and has been working fine for the last two years. Only recently have we started to experience this issue which SonarCloud have acknowledged as an issue.

Hi @15307

Thank you for the clarification.

Could you make sure that your SONAR_TOKEN is configured correctly in your CICD? Its misconfiguration (e.g. if it isn’t available in the context) may cause Could not find a default branch for project with key ‘MyOrg.Examle.Project’. Make sure project exists error on the scanner side.

This wouldn’t explain the issue you see on the browser side, though.

I’ll contact you privately to get more information about your project, and we can then examine the logs.

Anita

Hi @15307

Thank you for the additional information in the private message.

I was able to identify the error that prevents the query from working. Now, we’ll need to understand why this happens and provide a fix.

Unfortunately, I can’t promise when the fix will be provided. However, I’ll keep you up to date.

Anita

Hi Mark / @15307,

The issue should be fixed now. Could you please try again and let me know?

Regards,
Alex

1 Like

Hi Alex.

Can confirm that I can now list projects in the GUI and also the failing pipeline is now running without erroring regarding the project not existing.

Thanks for all your help.

3 Likes