Issue Summary
When git lfs is installed on the server downloading commits with LFS files results in a corrupted zip file
Steps to Reproduce
- Install LFS on server (note - this is NOT needed for LFS to work with Bitbucket Server - it may be there for other reasons)
- Enable LFS on a particular repository on Bitbucket Server
- Add and Commit (client side) an LFS tracked file - push the commit to server
- On Bitbucket Server UI, find the commit and click Download this commit
- The resulting archive (zip) file is corrupted and cannot be opened
Note: tested with Git 2.7.x
Expected Results
Zip file is not corrupted and can be opened
Actual Results
"An error occurred while loading the arhive" when trying to open zip file
The below exception is thrown in the atlassian-bitbucket.log file:
2020-04-30 14:41:20,179 ERROR [http-nio-7990-exec-4] o.a.c.c.C.[.[.[/bitbucket].[default] Servle t.service() for servlet [default] in context with path [/bitbucket] threw exception com.atlassian.bitbucket.scm.CommandFailedException: '/usr/bin/git archive --format=zip -- 76fce3a cdc9a70c0d01d58df736ea69d3b87f853' exited with code 128 saying: Downloading xxxxxxxxxxxx .jpg (29 KB) Error downloading object: xxxxxxxxx.jpg (07e0258): Smudge error: Error downloading xxxxxxxxxxxxx.jpg (07e0258894645f3faed1df8888796178e39eb9d4a041a9a5b2609521f04298a9): batch request: missing protocol: "" Errors logged to /var/atlassian/application-data/stash/shared/data/repositories/62/lfs/logs/20200 430T144120.159872096.log Use `git lfs logs last` to view the log. error: external filter git-lfs smudge -- %f failed 2 error: external filter git-lfs smudge -- %f failed fatal: Marionx_cover_generic.jpg: smudge filter lfs failed at com.atlassian.bitbucket.scm.DefaultCommandExitHandler.onError(DefaultCommandExitHandler.java:47) at com.atlassian.bitbucket.scm.git.command.GitCommandExitHandler.evaluateThrowable(GitCommandExitHandler.java: 111) at com.atlassian.bitbucket.scm.git.command.GitCommandExitHandler.onError(GitCommandExitHandler.java:208) at com.atlassian.bitbucket.scm.DefaultCommandExitHandler.onExit(DefaultCommandExitHandler.java:32) at com.atlassian.bitbucket.scm.BaseCommand.callExitHandler(BaseCommand.java:153) at com.atlassian.bitbucket.scm.BaseCommand$CommandFuture.internalGet(BaseCommand.java:287) at com.atlassian.bitbucket.scm.BaseCommand$CommandFuture.get(BaseCommand.java:251) at com.atlassian.bitbucket.scm.BaseCommand.call(BaseCommand.java:87) at com.atlassian.stash.internal.content.DefaultContentService.streamArchive(DefaultContentService.java:181) at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvoca tionHandler.java:26) at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.j ava:56) at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.jav a:60) at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCC LInterceptor.java:70) at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53) at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57) at com.atlassian.stash.internal.rest.content.ArchiveResource.lambda$getArchive$1(ArchiveResource.java:156) at com.atlassian.stash.internal.rest.filter.StreamingResponseFilter$ExceptionMappingStreamingResponse.lambda$write$0(StreamingResponseFilter .java:99) at com.atlassian.stash.internal.rest.filter.StreamingResponseFilter$AbstractStreamingExceptionMapper.stream(StreamingResponseFilter.java:50) at com.atlassian.stash.internal.rest.filter.StreamingResponseFilter$ExceptionMappingStreamingResponse.write(StreamingResponseFilter.java:99) at com.atlassian.stash.internal.rest.util.StreamingResponseProvider.writeTo(StreamingResponseProvider.java:58) at com.atlassian.stash.internal.rest.util.StreamingResponseProvider.writeTo(StreamingResponseProvider.java:39) at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24) at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24) at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24) at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24) at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24) at com.atlassian.analytics.client.filter.UniversalAnalyticsFilter.doFilter(UniversalAnalyticsFilter.java:92) at com.atlassian.analytics.client.filter.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:39) at com.atlassian.bitbucket.internal.xcode.web.XcodeUserAgentFilter.doFilter(XcodeUserAgentFilter.java:36) at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFil ... Caused by: com.atlassian.utils.process.ProcessException: Non-zero exit code: 128 at com.atlassian.bitbucket.scm.SummarizingProcessHandler.complete(SummarizingProcessHandler.java:47) at com.atlassian.utils.process.ExternalProcessImpl.wrapUpProcess(ExternalProcessImpl.java:667) at com.atlassian.utils.process.ExternalProcessImpl.finish(ExternalProcessImpl.java:163) at com.atlassian.bitbucket.scm.BaseCommand$CommandFuture.get(BaseCommand.java:249) ... 45 common frames omitted
Workaround
Uninstall git lfs from the server
git lfs uninstall
If you need to have an lfs client installed on the server for any reason you ran reinstall it with this option:
git lfs install --skip-smudge