"pullRequestRefGuardHook vetoed the push request" message seen in Bitbucket Server logs

Still need help?

The Atlassian Community is here for you.

Ask the community


Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

A repository repo1.git is mirrored onto another repository repo2.git. Git push operation fails with 'pre-receive hook declined' message on the client side. On the server side, "'pullRequestRefGuardHook' vetoed the push request" message is seen in the logs.

Environment

Bitbucket 8.9.3

Diagnosis

A repository repo1.git is mirrored onto another repository repo2.git. The operation is done by running the command "git clone --mirror <clone_url_for_repo1.git>" and pushed using the command "git push --mirror <remote_url_repo2.git>".

On the Git client side, we see the below message:

! [remote rejected]       branch1 -> branch1 (pre-receive hook declined)
! [remote rejected]       branch2 -> branch2 (pre-receive hook declined)

On the Bitbucket server side, in atlassian-bitbucket.log, we see the below message:

<DATE-TIMESTAMP> INFO [mesh-grpc-request:thread-2524] XXXXXXXXXXXX \*1XXXXXXx730x4106118x1 1htkkkz XX.XX.XX.XX SSH - git-receive-pack '/proj/repo2.git' c.a.s.i.h.r.DefaultRepositoryHookService [proj/repo2[12]] hook 'pullRequestRefGuardHook' vetoed the push request

Cause

'pullRequestRefGuardHook' is a system-level hook that prevents create/update/delete operations for refs that are reserved for Pull requests. The internal Bitbucket refs on the repository repo2.git are being altered due to --mirror option that is declined through the system hook 'pullRequestRefGuardHook'.

The issue is that when the repository was cloned from the source, the clone fetched the pull request references as well. When a push to the remote is done in the destination, the rewritten PR references are pushed as well, which Bitbucket does not allow. 

Solution

Follow the steps documented in the KB: Getting "pre-receive hook declined" error while trying to move repository from one project to another in Bitbucket Server.

Last modified on Feb 12, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.