SonarCloud API returns "Project doesn't exist" (404) for projects that exist in the UI

Hello everyone,

I’m experiencing an issue with the SonarCloud API when trying to access metrics for specific projects in my organization. I’m using Apache DevLake (an open-source dev data platform) to collect and analyze data from SonarCloud, but I’m encountering consistent 404 errors for certain repositories.

Issue Details

When DevLake makes API calls to the measures/component_tree endpoint for a specific project, SonarCloud returns a 404 error with the message “Project doesn’t exist”, even though the project definitely exists and is accessible through the SonarCloud UI.

API Call Details

The failing API call looks like this:

GET measures/component_tree
query: map[
 component:[organization_project-name]
 metricKeys:[duplicated_lines_density,duplicated_
blocks,duplicated_lines,duplicated_
files,complexity,cognitive_complexity,effort_to_
reach_maintainability_rating_a,lines]
 p:[1]
 ps:[100]
 qualifiers:[FIL]
]

Error Response

Response: {"errors":[{"msg":"Project doesn\u0027t 
exist"}]} (404)

What I’ve Checked

  1. The project exists in my SonarCloud organization and is accessible through the UI
  2. I can access other projects in the same organization through the API without issues
  3. I’ve verified my authentication credentials are correct (other API calls work)
  4. I’ve confirmed the organization key is correctly configured

Questions

  1. Is there a specific format requirement for project keys when using the API that might be different from what’s shown in the UI?
  2. Could there be an issue with how project keys are constructed when making API calls?
  3. Are there any known issues with the measures/component_tree endpoint for certain project configurations?
  4. Is there a way to debug or get more detailed error information from the API?

Any guidance on resolving this issue would be greatly appreciated. I’m happy to provide additional information if needed.

Thank you!

We started getting the “project doesn’t exist” message a few hours ago in our pipelines. They don’t show anything wrong on the status page but something had to have changed somewhere.

Hey there.

There’s a bit more to this story than I’m letting on right now (@tcs-cclaflin you’re right, something did change).

In the meantime, please ensure that the appropriate permissions have been assigned to the relevant user(s) or group(s), either at the global or project level.

@Rafael_Couto: For you, ensure that the Browse Project permission is granted at the project level for the projects you’re querying GET api/measures/component_tree

You can always double-check the API calls you’re making and compare to those being made in the UI (like when browsing the Measures tab of your project) using the following guide:

@tcs-cclaflin: For you, confirm that the Execute Analysis permission is assigned at either the org-level, or for the affected projects

You should probably focus on the Members group. Don’t try setting permissions for the Anyone group (you won’t see this group for much longer)

It might also be a good time to revisit any permission templates to make sure the right permissions are being assigned not only to existing projects, but to new projects as well.

that was the issue. Had to give our robot account execute analysis permissions. thank you.

Thanks for the reply Colin it was effectively an issue related with permissions :slight_smile:

Thanks a lot!

To close the loop here: