Server error while fetching/pushing LFS files from/to Bitbucket Cloud
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
Summary
While performing Git LFS fetch/push, you may encounter the following errors.
$ git lfs fetch --all
fetch: 1871 object(s) found, done.
fetch: Fetching all references...
[xyzabc] Object does not exist on the server: [404] Object does not exist on the server
error: failed to fetch some objects from 'https://bitbucket.org/workspace/repo.git/info/lfs'
$ git lfs push origin --all
LFS upload failed:cts: 88% (7/8), 6.6 MB | 0 B/s
Uploading LFS objects: 88% (7/8), 6.6 MB | 0 B/s, done.
(corrupt) LFS-File (xyzabc)
hint: Your push was rejected due to missing or corrupt local objects.
hint: You can disable this check with: 'git config lfs.allowincompletepush true'
$ git lfs push origin --object-id xyzabc
Fatal error: Server error: https://bitbucket.org/workspace/repo/info/lfs/object/verify?upload_id=uvw
Uploading LFS objects: 0% (0/1), 40 B | 0 B/s, done.
Errors logged to /localpath/lfs/gitlfs2/.git/lfs/logs/20221230T165135.211306.log
Use `git lfs logs last` to view the log.
Diagnosis
The above errors indicate that the LFS file being attempted to fetch/push is corrupted. If you access the file through the commit https://bitbucket.org/workspace/repo/commits/<commit-h/LFS-File, you will notice the message "the file is missing; your file may not have been uploaded correctly."
The correctly uploaded LFS file will show the message below.
Sometimes, the following errors may occur if an incorrect file is placed under .git/lfs/objects/xy/za/xyzabc
directory.
- Object does not exist on the server
- error: failed to fetch some objects
- Your push was rejected due to missing or corrupt local objects
Solution
Please follow the steps below to fix the errors mentioned above:
- In the local git repository, check the
shasum
value of the LFS object.
$ shasum -a 256 .git/lfs/objects/xy/za/xyzabc
- Go to the corrupted file path in the remote repository at https://bitbucket.org/workspace/repo/commits/<commit-h/LFS-File, click on three dots →, click on Open raw, which should download the corrupted file.
Check the shasum
value of the downloaded LFS object and verify if the shasum
values are the same.
$ shasum -a 256 <downloaded-file-path>/xyzabc
In the case when the shasum
values don't match, you may encounter errors such as "Object does not exist on the server"
, "error: failed to fetch some objects
", and "Your push was rejected due to missing or corrupt local objects
".
- Replace the downloaded file in the ".git/lfs/objects/xy/za/xyzabc" path and attempt "git lfs fetch --all" and "git lfs push origin --all" which should work without any errors.
If you want to delete the corrupted LFS file, follow the steps on how to delete Git LFS files from a repository. You need to use the BFG tool to remove the pointers in the core repository. Then, a repository admin can delete Git LFS files from the repository as follows:
Go to the Settings page for the repository and click Git LFS to view the list of all LFS files in that repository.
Delete the LFS files using the actions menu.
Once the LFS file pointers, the LFS file is deleted, and the history is re-written and will not encounter any download errors.