-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Medium
-
None
-
Affects Version/s: 8.10.0, 8.16.0, 8.17.0
-
Component/s: Repository - Branch Permissions
-
4
-
Severity 2 - Major
-
4
Issue Summary
This is reproducible on Data Center: (yes)
We encounter a problem in Bitbucket.
- We have a project-level branch permission for default branch ("master") where deletion and rewriting history is prevented.
- One of our repo does not have any branch defined (especially not master),
- In this repo we have existing commits with tags.
-> when we click on "Branch permissions" in the repo we get a page displaying "500 Internal server error"
-> when we try to create a branch called "master" via bitbucket on one of the tags we get an info stating
"Branch creation cancelled. Repository hook com.atlassian.bitbucket.server.bitbucket-ref-restriction:restrictionEnforcerHook failed No default branch is defined"
When we remove the branch permission from the project, we are able to create the branch.
In our point of view
- it should be possible to create a branch
- there should be no error-500 page in this case
------------------------------------
BR Michael
Steps to Reproduce
We need to simulate the case with GIT repositories without branches that were imported into the previous Bitbucket version, 7.16. The steps below contain copying .git of some existing repo to get to the point right after the upgrade from 7.16 to 8.16 with existing repos without branches.
- Tested with Bitbucket 8.16.0 and 8.17.0, it behaves the same.
- In Bitbucket web UI, create a new GIT repository ("branchless"), and let Bitbucket select the default branch name.
- Clone that empty repository to workstation, for example
git clone ssh://git@BITBUCKET_HOST/dcnw1/branchless.git - On the workstation, copy the .git directory from some existing small repository to the newly cloned one.
Execute the next steps in the newly cloned repo. - Edit the file .git/config and remove references to old branches and remotes.
- Add remote, point to new repository:
git remote add origin ssh://git@BITBUCKET_HOST/dcnw1/branchless.git - Add tag:
git tag -a tag1 -m "tag 1" - Checkout to tag - detached HEAD state
git checkout tag1
- Remove "master" branch
git branch -d master
- Push tag
git push origin tag1
- We now have some files in Bitbucket's Git repository, without any branch but with one tag.
This is the situation right after the upgrade from Bitbucket 7.16 to 8.16. - In Bitbucket web UI, go to "Repository settings / Branch permissions" and confirm you see the message The default branch is set to "refs/heads/master" but does not exist. Configure the default branch in the repository settings. - there is no error shown.
- Now, go to Bitbucket web UI and define branch permission on a project level: "Add permission", select "Branching model" and select "Development - Default branch", select/check any restriction (for example, "Prevent deletion"). Click "Save".
- Now, again go to the "branchless" Git repository in Bitbucket Web UI, then "Repository settings / Branch permissions". There is "500. Internal server error"
- From now on, it is not possible to push tags to this repository anymore:
git tag -a tag2 -m "tag 2" git push origin tag2 Enumerating objects: 1, done. Counting objects: 100% (1/1), done. Writing objects: 100% (1/1), 160 bytes | 160.00 KiB/s, done. Total 1 (delta 0), reused 0 (delta 0), pack-reused 0 remote: Repository hook com.atlassian.bitbucket.server.bitbucket-ref-restriction:restrictionEnforcerHook failed remote: No default branch is defined To ssh:/BITBUCKET_HOST/dcnw1/branchless-2.git ! [remote rejected] tag2 -> tag2 (pre-receive hook declined) error: failed to push some refs to 'ssh://BITBUCKET_HOST/dcnw1/branchless-2.git'
Expected Results
- No error shown in repo's "Branch permissions".
- Able to push tags, branches.
Actual Results
- Repo's "Branch permissions" shows Error 500
- It is not possible to push to the repo:
remote: Repository hook com.atlassian.bitbucket.server.bitbucket-ref-restriction:restrictionEnforcerHook failed remote: No default branch is defined To ssh:/BITBUCKET_HOST/dcnw1/branchless-2.git ! [remote rejected] tag2 -> tag2 (pre-receive hook declined) error: failed to push some refs to 'ssh://BITBUCKET_HOST/dcnw1/branchless-2.git'
Workaround
Workaround is to remove branch permissions that are set on project level.