git lfs batch error: Fatal error: Server error when pushing lfs tracked files
Asked by Viktor Govze:

Dear all,

I am having issues when pushing some .pdf files onto the Bitbucket server using git lfs. I didn't use lfs before, so I did everything as described on [https://www.atlassian.com/git/tutorials/git-lfs#creating-new-repository.](https://www.atlassian.com/git/tutorials/git-lfs#creating-new-repository) This procedure works if I use GitHub, which gives me the impression that I am not doing it wrong - it also tracks the LFS files correctly.

I get the following git lfs error log when doing it with Bitbucket (exactly the same conditions as for GitHub):

---------------------------------------------------------------------------------

git-lfs/3.4.0 (GitHub; windows amd64; go 1.20.6; git d06d6e9e)  
git version 2.42.0.windows.2

$ git-lfs pre-push origin git@bitbucket.org:XXXXXX.git  
batch response: Fatal error: Server error: <https://bitbucket.org/%7B%7D/%7B27383ad9-019b-4a18-9b83-20d5b21b3076%7D/info/lfs/objects/batch>

Server error: <https://bitbucket.org/%7B%7D/%7B27383ad9-019b-4a18-9b83-20d5b21b3076%7D/info/lfs/objects/batch>  
github.com/git-lfs/git-lfs/v3/errors.Errorf  
github.com/git-lfs/git-lfs/v3/errors/errors.go:69  
github.com/git-lfs/git-lfs/v3/lfshttp.defaultError  
github.com/git-lfs/git-lfs/v3/lfshttp/errors.go:126  
github.com/git-lfs/git-lfs/v3/lfshttp.(\*Client).handleResponse  
github.com/git-lfs/git-lfs/v3/lfshttp/errors.go:52  
github.com/git-lfs/git-lfs/v3/lfshttp.(\*Client).DoWithRedirect  
github.com/git-lfs/git-lfs/v3/lfshttp/client.go:335  
github.com/git-lfs/git-lfs/v3/lfsapi.(\*Client).doWithCreds  
github.com/git-lfs/git-lfs/v3/lfsapi/auth.go:105  
github.com/git-lfs/git-lfs/v3/lfsapi.(\*Client).doWithAuth  
github.com/git-lfs/git-lfs/v3/lfsapi/auth.go:68  
github.com/git-lfs/git-lfs/v3/lfsapi.(\*Client).DoWithAuth  
github.com/git-lfs/git-lfs/v3/lfsapi/auth.go:26  
github.com/git-lfs/git-lfs/v3/lfsapi.(\*Client).DoAPIRequestWithAuth  
github.com/git-lfs/git-lfs/v3/lfsapi/auth.go:57  
github.com/git-lfs/git-lfs/v3/tq.(\*tqClient).Batch  
github.com/git-lfs/git-lfs/v3/tq/api.go:94  
github.com/git-lfs/git-lfs/v3/tq.Batch  
github.com/git-lfs/git-lfs/v3/tq/api.go:45  
github.com/git-lfs/git-lfs/v3/tq.(\*TransferQueue).enqueueAndCollectRetriesFor  
github.com/git-lfs/git-lfs/v3/tq/transfer_queue.go:581  
github.com/git-lfs/git-lfs/v3/tq.(\*TransferQueue).collectBatches.func1  
github.com/git-lfs/git-lfs/v3/tq/transfer_queue.go:470  
runtime.goexit  
runtime/asm_amd64.s:1598  
Fatal error  
github.com/git-lfs/git-lfs/v3/errors.newWrappedError  
github.com/git-lfs/git-lfs/v3/errors/types.go:229  
github.com/git-lfs/git-lfs/v3/errors.NewFatalError  
github.com/git-lfs/git-lfs/v3/errors/types.go:273  
github.com/git-lfs/git-lfs/v3/lfshttp.(\*Client).handleResponse  
github.com/git-lfs/git-lfs/v3/lfshttp/errors.go:76  
github.com/git-lfs/git-lfs/v3/lfshttp.(\*Client).DoWithRedirect  
github.com/git-lfs/git-lfs/v3/lfshttp/client.go:335  
github.com/git-lfs/git-lfs/v3/lfsapi.(\*Client).doWithCreds  
github.com/git-lfs/git-lfs/v3/lfsapi/auth.go:105  
github.com/git-lfs/git-lfs/v3/lfsapi.(\*Client).doWithAuth  
github.com/git-lfs/git-lfs/v3/lfsapi/auth.go:68  
github.com/git-lfs/git-lfs/v3/lfsapi.(\*Client).DoWithAuth  
github.com/git-lfs/git-lfs/v3/lfsapi/auth.go:26  
github.com/git-lfs/git-lfs/v3/lfsapi.(\*Client).DoAPIRequestWithAuth  
github.com/git-lfs/git-lfs/v3/lfsapi/auth.go:57  
github.com/git-lfs/git-lfs/v3/tq.(\*tqClient).Batch  
github.com/git-lfs/git-lfs/v3/tq/api.go:94  
github.com/git-lfs/git-lfs/v3/tq.Batch  
github.com/git-lfs/git-lfs/v3/tq/api.go:45  
github.com/git-lfs/git-lfs/v3/tq.(\*TransferQueue).enqueueAndCollectRetriesFor  
github.com/git-lfs/git-lfs/v3/tq/transfer_queue.go:581  
github.com/git-lfs/git-lfs/v3/tq.(\*TransferQueue).collectBatches.func1  
github.com/git-lfs/git-lfs/v3/tq/transfer_queue.go:470  
runtime.goexit  
runtime/asm_amd64.s:1598  
batch response  
github.com/git-lfs/git-lfs/v3/errors.newWrappedError  
github.com/git-lfs/git-lfs/v3/errors/types.go:229  
github.com/git-lfs/git-lfs/v3/errors.Wrap  
github.com/git-lfs/git-lfs/v3/errors/errors.go:74  
github.com/git-lfs/git-lfs/v3/tq.(\*tqClient).Batch  
github.com/git-lfs/git-lfs/v3/tq/api.go:97  
github.com/git-lfs/git-lfs/v3/tq.Batch  
github.com/git-lfs/git-lfs/v3/tq/api.go:45  
github.com/git-lfs/git-lfs/v3/tq.(\*TransferQueue).enqueueAndCollectRetriesFor  
github.com/git-lfs/git-lfs/v3/tq/transfer_queue.go:581  
github.com/git-lfs/git-lfs/v3/tq.(\*TransferQueue).collectBatches.func1  
github.com/git-lfs/git-lfs/v3/tq/transfer_queue.go:470  
runtime.goexit  
runtime/asm_amd64.s:1598

Current time in UTC:  
2023-10-03 12:37:17

Environment:  
LocalWorkingDir=C:\\Users\\XXXXXX  
LocalGitDir=C:\\Users\\XXXXXX\\.git  
LocalGitStorageDir=C:\\Users\\XXXXXX\\.git  
LocalMediaDir=C:\\Users\\XXXXXX\\.git\\lfs\\objects  
LocalReferenceDirs=  
TempDir=C:\\Users\\XXXXXX\\.git\\lfs\\tmp  
ConcurrentTransfers=8  
TusTransfers=false  
BasicTransfersOnly=false  
SkipDownloadErrors=false  
FetchRecentAlways=false  
FetchRecentRefsDays=7  
FetchRecentCommitsDays=0  
FetchRecentRefsIncludeRemotes=true  
PruneOffsetDays=3  
PruneVerifyRemoteAlways=false  
PruneRemoteName=origin  
LfsStorageDir=C:\\Users\\XXXXXX\\.git\\lfs  
AccessDownload=none  
AccessUpload=none  
DownloadTransfers=basic,lfs-standalone-file,ssh  
UploadTransfers=basic,lfs-standalone-file,ssh  
GIT_EXEC_PATH=C:/Program Files/Git/mingw64/libexec/git-core  
GIT_LFS_PATH=C:\\Program Files\\Git LFS  
GIT_PREFIX=

---------------------------------------------------------------------------------

The issue appears to be similar to the one reported <https://github.com/git-lfs/git-lfs/issues/1858>, but I am not sure if it's still aplicable.

If anyone has any idea on what to do, I'd be happy to know. To my best knowledge, there is no post on this topic on this forum.

Best regards,

Viktor


Answers:
author: Theodora Boudale
body: Hi everyone,

We identified a bug that was causing issues with pushing LFS files to Bitbucket Cloud repositories.

A fix for this issue has been deployed to production. Please try to push again now, and let us know if you encounter any further problems.

Kind regards,  
Theodora


author: ????????? ???????
body: Oh, I have a similar problem. For some reason I think Bitbucket has the problem, because the service is giving away 500


author: ????????? ???????
body: I found the problem. In order for the files to upload, you need to first push .gitattributes to the remote repository


author: viakmaky
body: I am experiencing the exact same error with the same stacktrace on a new repository I created yesterday.

Everything points to it being a server side issue with Bitbucket, as I can't see anything in my end I could change that would affect it.

comments: author: ????????? ???????
body: See my last answer. you need to first push .gitattributes to the remote repository


author: viakmaky
body: They actually fixed the issue on the server since yesterday. Push on the same repo now works without any changes.

I already followed the official guide which had you push .gitattributes first in a separate commit, so that wasn't my issue.


author: psychobolt
body: I am having similiar issue with \`git lfs push\` as documented following this guide. <https://docs.github.com/en/repositories/creating-and-managing-repositories/duplicating-a-repository#mirroring-a-repository-that-contains-git-large-file-storage-objects>


Tags: bitbucket-cloud

cloud