Cannot access newly created project / error creating project

Hi Team,

I’d be grateful for help with the following issue that is blocking us from adding projects to our Team subscription.

Template information:

  • ALM used : Azure DevOps
  • CI system used : Azure DevOps
  • Scanner command used : N/A
  • Languages of the repository: not relevant / C#, HTML, CSS , JS
  • URL: private project within a Team subscription
  • Error observed :
  1. Cannot access newly created project (“The requested project does not exist, or you have not been granted access” in project/overview?id=[new-project-key]).
  2. Error seen immediately after creating the project via web ui.
  3. Error seen despite enabling any visible permissions (administer organization, create projects, execute analysis, administer quality gates, administer quality profiles).
  4. Error seen despite the project having been apparently created (re-using the same project key gives error “Could not create Project, key already exists: [project key]” ).
  5. Same error for importing single repository, by monorepo setup, or by manual setup
  6. Same error seen by a colleague (also cannot successfully create new project in the same organization despite apparently having the necessary permissions).
  7. The functionality used to work - we have a number of projects set up including CI CD pipelines.
  • Steps to reproduce
    Create a new project in our organization using any method. EXPECTED: project details page displayed, and new project can be found by filtering the organization projects’ list. ACTUAL: Error "The requested project does not exist , or you have not been granted access” and project is not listed among the organization’s projects.

  • Potential workaround: none found

kind regards,
Tadeusz

Hey there.

In SonarCloud, you must be granted project-level permissions to view a project, regardless of your organization-level permissions.

What you’re describing sounds like what happens when the permission template that gets applied to these new projects doesn’t grant the project creator permissions on the project, either through a group the project creator belongs to or the special Creators option in the permission template setup.

So, your first stop should be validating and fixing the permission template.

Now – about the projects you’ve already created. If nobody else in your organization has access to these projects, to restore access, an organization admin can use the Web API POST api/permissions/add_user to restore access the project.

Some documentation on how to use the Web API can be found here.

What this looks like is an API call like:

curl --header 'Authorization: Bearer MY_TOKEN' -X POST 'https://sonarcloud.io/api/permissions/add_user?projectKey=PROJECT_KEY&login=LOGIN&permission=admin&organization=ORG_KEY'
curl --header 'Authorization: Bearer MY_TOKEN' -X POST 'https://sonarcloud.io/api/permissions/add_user?projectKey=PROJECT_KEY&login=LOGIN&permission=user&organization=ORG_KEY'

Replacing MY_TOKEN, PROJECT_KEY, LOGIN, and ORG_KEY with the right values. Your login will be found under My Account

POST api/projects/delete is another option if you just want to recreate the projects after fixing the permission template.

This is all too complicated in my opinion, but right now we lack a better solution for Team Plan org admins to restore access to projects they have no access to (Enterprise Plan users have access to a global project management page)

1 Like

Thank you, that was a very helpful response :slight_smile:

I’ve managed to use the API’s to resolve our issue

1 Like