Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Problem deleting a repo

ab36245 September 26, 2021

I am experimenting with the bitbucket api to create a new repo.

When creating the repo the only value I set in the POST request was the scm:

 

{

"scm": "git"

}

 

It seems to work fine, and the repo is both GETable via the api and visible through the web interface. However, when I go to delete it via the api I get an error:

 

{

"type": "error",

"error": {

"message": "Something went wrong",

"id": "89bd52cc05d4470a9087f23da8d3a23f"

}

}

 

I also cannot delete the repo via the web interface. I get a similar error in a dialog box in the bottom left hand corner of the screen.

The error message is not very informative :-) The only hint I get that something is wrong with the repo is if I try to update the repository settings I get a message:

Please fix errors below

Main branch needs your attention

The value in the main branch section is:

Main branch

master
Select a valid choice. master is not one of the available choices.
However there are no options available in the list to choose from. (This is actually the same as my other repos, all created through the web interface and which seem to work without a problem).

I assume that there is a permission (or some other) setting missing, but it is not clear to me what. I would very much like to be able to use the api to create repos, but do not want to create a string of repos which I can't then edit successfully.

Any thoughts as to what is wrong?

Thanks!

1 answer

0 votes
Caroline R
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 27, 2021

Hi, @ab36245! Welcome to the community! 

I reviewed the code you shared in your message and confirmed that it corresponds to the below error:

ProjectPrivacyException: A repository in a private project cannot be publicly visible.

So the repository you are trying to delete is set as public, but the project that has this repository is private. This is the cause of this issue. 

In this case, you can set this repository as private by following the next steps and then try to delete the repo:

  • Access the repository > Repository settings
  • Under the Repository details section, find the "This is a private repository" option and check this box; 
  • Click Save changes

Also, if you want to create a repository using the API and make it private, you can use the following request:

curl -X POST -u username:AppPassword -H "Content-Type: application/json" -d '{"scm": "git", "is_private":"true", "project": { "key": "{inform_the_project_key_here}" } }' https://api.bitbucket.org/2.0/repositories/{workspacename}/{repository_name}

I hope this helps, but do let me know if you have any questions. 

Kind regards,
Caroline

ab36245 September 27, 2021

Hi @Caroline R

Thanks very much for the quick reply.

Your diagnosis is quite correct. But unfortunately the fix wasn't quite as easy as you described it.

tl;dr I can fix the problem, but only by going through the api.

Just in case you want the details...

If I GET the repo information via the API the response includes:

"is_private": false

This is totally consistent with what you suggest.

But, if I try to change that setting via the web app (via the repo's Repository Settings > Repository Details screen as you suggest), the "This is a private repository" setting is turned on (ticked) but also disabled (grayed out):

image.png

I cannot change the setting. Obviously this is an artefact as it does not agree with the repos actual "is_private" value. I suspect that the UI is simply not allowing the repo's state to be changed because the project it is in is private.

I then thought that maybe I could temporarily make the project public, then change the access on the repo.

But if I go to the Project settings page for the relevant project the setting for privacy is also turned on (ticked) but disabled (grayed out):

image.png

So, because I have (unintentionally) created a public repo in a private project, I seem to be stuck! In this state I can't change the repo setting from public to private and I can't change the project setting from private to public!

This seems to be a bug in the web app, but originating from the fact that the api POST request allowed the creation of a public repo (by not specifying a value for "is_private") in a private project (by not specifying a project and having it default to the oldest project, which in my case is private).

However, you'll be pleased to know that the api also came to my rescue. If I update the repo via a PUT setting

{
"is_private": true
}

this update works. Once that's done I can delete the repo.

So, a minor request. The API POST request probably shouldn't be able to create a repo in a state that cannot be manipulated via the web. A rejected request saying that I couldn't create a public repo in a private project would have been perfect in my case.

Thanks again for your help

Like Caroline R likes this
Caroline R
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 28, 2021

Hi, @ab36245!

Thank you so much for sharing this information here, I really appreciate this.

I confirmed this really is a bug and for this reason, I raised the following bug request to fix this issue:

Our development team will post an update on the bug report when this is fixed. If you are not familiar with our Bug Request Policy, you can read more about it here

You can add yourself as a watcher (by selecting the Start watching this issue link in the bug report) if you'd like to get notified via email on any updates and also select the This affects my team link to indicate you are affected by this issue. 

Kind regards,
Caroline

Like ab36245 likes this
ab36245 September 28, 2021

Thanks @Caroline R I really appreciate your responsiveness and assistance

Caroline R
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 29, 2021

I'm glad to help, @ab36245

Kind regards,
Caroline

Saurabh Patwardhan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 15, 2021

This is still an issue.

Unable to delete the repositories created using api.

Caroline R
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 15, 2021

Hi, @Saurabh Patwardhan

My suggestion would be that you create a separate question for your issue, providing details on the errors you see and also whether the problem occurs on Bitbucket Cloud or Bitbucket Server. 

We generally encourage users to create a new question for their issue instead of posting on someone else's question because 1) the root cause and resolution may be different for each case 2) a question can become cluttered and difficult to follow if we try to troubleshoot multiple users' issues in it.  

Please feel free to let me know if you have any questions. 

Kind regards,
Caroline 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events