Push is failing with "failed to read objects <object_id>: Permission Denied" error in Bitbucket Data Center
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
While trying to perform the push to the Bitbucket Data Center repository, it is failing with the following error: "failed to read objects <object_id>: Permission Denied"
Environment
Bitbucket Data Center 7.21.6
Is applicable to Bitbucket Data Center 8.x
Diagnosis
Run the following command on the Bitbucket server machine under the Repository path or location. The Repository path or location, you can find from Bitbucket UI → Select Repository → Repository Settings → Location path.
a. git fsck --no-dangling
b. git fsck --full
Cause
This issue generally occurs due to permission or ownership issues of the objects (highlighted in the error message) present on the Bitbucket server repository path for the user.
For example, The object should be owned by bitbucket_user (the user with which Bitbucket service runs, by default, it is atlbitbucket user). However, it may be owned by root user causing permission denied errors.
Solution
The issue should be resolved after correcting the ownership of the user and group of objects or permissions of objects on the Bitbucket server machine.