Bitbucket Data Center shows "git cat-file -t refs/heads/master:' exited with code 128 saying: fatal: not a git repository" error on browsing the repository
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles 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
On browsing the repository page, an error message "'git cat-file -t refs/heads/master:'' exited with code 128 saying: fatal: not a git repository (or any parent up to mount point /var/atlassian/application-data/bitbucket) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set)" appears.
Environment
- Solution verified in Bitbucket Data Center 8.19.3
- Applicable in other Bitbucket Data Center versions.
Diagnosis
The atlassian-bitbucket.log
will have the following error stack trace:
2024-08-07 14:06:10,752 ERROR [http-nio-7990-exec-7] user1 @F1MA5Vx846x552x0 je9tkz 172.29.XX.XX,10.229.XX.XX "GET /projects/PRO1/repos/repo5/browse HTTP/1.1" c.a.s.i.w.HandlerExceptionResolverImpl 'git cat-file -t refs/heads/master:' exited with code 128 saying: fatal: not a git repository (or any parent up to mount point /var/atlassian/application-data/bitbucket)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
com.atlassian.bitbucket.scm.CommandFailedException: 'git cat-file -t refs/heads/master:' exited with code 128 saying: fatal: not a git repository (or any parent up to mount point /var/atlassian/application-data/bitbucket)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
at com.atlassian.stash.internal.scm.git.mesh.DefaultErrorTranslator.translateDefault(DefaultErrorTranslator.java:192)
.
.
.
at com.atlassian.stash.internal.hazelcast.ConfigurableWebFilter.doFilter(ConfigurableWebFilter.java:38)
at java.base/java.lang.Thread.run(Thread.java:829)
... 374 frames trimmed
Caused by: io.grpc.StatusRuntimeException: INTERNAL: [git cat-file -t refs/heads/master:] exited with code 128 saying: fatal: not a git repository (or any parent up to mount point /var/atlassian/application-data/bitbucket)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
at io.grpc.Status.asRuntimeException(Status.java:535)
at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:487)
at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39)
at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23)
.
.
.
at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:70)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:743)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:722)
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
... 2 common frames omitted
Please refer to Identifying a repository's ID in Bitbucket Data Center KB article to locate repository path on disk and repository id.
Cause:
This error may occur due to one of the following causes.
Cause 1: The repository directory at
<Bitbucket-Home-Directory>/shared/data/repositories/<repository-id>
is missing the refs subdirectory.- Cause 2: Bitbucket cannot access data in the objects subdirectory, which is located within <Bitbucket-Home-Directory>/shared/data/repositories/<repository-id>, because the OS user running the Bitbucket process lacks the necessary
read-write
permissions.
Solution:
- Resolution1: Restore the
refs
directory from the most recent backup. - Resolution2: Update the permissions on the
objects
subdirectory located at <Bitbucket-Home-Directory>/shared/data/repositories/<repository-id> to ensure OS user running the Bitbucket process can read, write, and execute the necessary files.