Skip to content

Help triaging git-lfs checkout failure #4974

Description

@oderby

Describe the issue
In our CI environment, we run git lfs fetch followed by a git lfs checkout to properly pull down/populate large fixture objects in our repo from git LFS pointers, needed to run our tests. Randomly (anecdotally, seems to be about 5% of the time) the git lfs checkout step silently fails (see logs below), leaving the local repo checkout in a dirty state (unexpected/undesired behavior for CI environment for obvious reasons)

To break this apart, there's at least 2 issues/problems for us here:

  1. git lfs checkout is failing (see error message and stack trace below) and we cannot figure out why
  2. when the above failure occurs, the git lfs checkout process still exits cleanly (exit code 0), despite failing and leaving our repo in a dirty state.

Any help in debugging the first problem would be very much appreciated, and any thoughts on if the second is an expected behavior (and if so, why) or if it's worth opening a separate bug report issue would also be helpful. Thanks!

System environment
CircleCI job, running with their Docker Executor, using a variety of images (observed on cimg/go:1.17, cimg/ruby:2.7.5-node, cimg/node:14.18.1-browsers, cimg/node:14.18.1, etc)

git lfs is not installed by default on any of these base cimg images, so it is installed each run using the following bash

  # Skip installing git-lfs if already present
  if ! command -v git-lfs &> /dev/null; then
    curl -sL https://github.com/git-lfs/git-lfs/releases/download/v3.1.2/git-lfs-linux-amd64-v3.1.2.tar.gz -o git-lfs.tar.gz \
    && tar -xzf git-lfs.tar.gz \
    && sudo ./install.sh
  fi
  git-lfs --version  # Print out version for debugging
  cd ~/build && git lfs install  # Finally, install it in the repo

Error logged to ~/build/.git/lfs/logs/20220428T065800.570779134.log

git-lfs/3.1.2 (GitHub; linux amd64; go 1.17.6)
git version 2.35.1

$ git-lfs checkout
Error updating the Git index:
panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
github.com/git-lfs/git-lfs/v3/git.(*FilterProcessScanner).readRequest(0xc0000a3b48)
	work/git-lfs/git-lfs/git/filter_process_scanner.go:188 +0x245
github.com/git-lfs/git-lfs/v3/git.(*FilterProcessScanner).Scan(0xc0000a3b48)
	work/git-lfs/git-lfs/git/filter_process_scanner.go:152 +0x76
github.com/git-lfs/git-lfs/v3/commands.filterCommand(0xc000125900, {0x9be0d9, 0x0, 0x0})
	work/git-lfs/git-lfs/commands/command_filter_process.go:74 +0x345
github.com/spf13/cobra.(*Command).execute(0xc000125900, {0xe710b8, 0x0, 0x0})
	go/pkg/mod/github.com/spf13/[email protected]/command.go:766 +0x5f8
github.com/spf13/cobra.(*Command).ExecuteC(0xc000124000)
	go/pkg/mod/github.com/spf13/[email protected]/command.go:852 +0x2dc
github.com/spf13/cobra.(*Command).Execute(...)
	go/pkg/mod/github.com/spf13/[email protected]/command.go:800
github.com/git-lfs/git-lfs/v3/commands.Run()
	work/git-lfs/git-lfs/commands/run.go:107 +0x2ed
main.main()
	work/git-lfs/git-lfs/git-lfs.go:34 +0xea
error: packet write with format failed
error: external filter 'git-lfs filter-process' failed
fatal: title-vi/fixtures/orig_map_trips.json: clean filter 'lfs' failed


exit status 128

Current time in UTC:
2022-04-28 06:58:00

Environment:
LocalWorkingDir=/home/circleci/remix
LocalGitDir=/home/circleci/remix/.git
LocalGitStorageDir=/home/circleci/remix/.git
LocalMediaDir=/home/circleci/remix/.git/lfs/objects
LocalReferenceDirs=
TempDir=/home/circleci/remix/.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=/home/circleci/remix/.git/lfs
AccessDownload=none
AccessUpload=none
DownloadTransfers=basic,lfs-standalone-file,ssh
UploadTransfers=basic,lfs-standalone-file,ssh
GIT_EXEC_PATH=/usr/lib/git-core
GIT_TRACE=1

Client IP addresses:
192.168.240.3

If relevant, include the output of git config -l as a code block.

url.ssh://[email protected]=https://github.com
gc.auto=0
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
[email protected]:[redacted]/[redacted].git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
lfs.repositoryformatversion=0

Output of git lfs env

git-lfs/3.1.2 (GitHub; linux amd64; go 1.17.6)
git version 2.33.0

Endpoint=https://github.com/[redacted]/[redacted].git/info/lfs (auth=none)
  [email protected]:[redacted]/[redacted].git
LocalWorkingDir=/home/circleci/build
LocalGitDir=/home/circleci/build/.git
LocalGitStorageDir=/home/circleci/build/.git
LocalMediaDir=/home/circleci/build/.git/lfs/objects
LocalReferenceDirs=
TempDir=/home/circleci/build/.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=/home/circleci/build/.git/lfs
AccessDownload=none
AccessUpload=none
DownloadTransfers=basic,lfs-standalone-file,ssh
UploadTransfers=basic,lfs-standalone-file,ssh
GIT_EXEC_PATH=/usr/lib/git-core
git config filter.lfs.process = "git-lfs filter-process"
git config filter.lfs.smudge = "git-lfs smudge -- %f"
git config filter.lfs.clean = "git-lfs clean -- %f"

Additional context
I was able to capture a failure while running git lfs fetch && GIT_TRACE=1 git lfs checkout. You can view the trace output in this gist (omitting only the redundant listing of all files in our repo and other repeated lines)

Activity

  1. changed the title [-]Help triaging git-lfs failure/crash[/-] [+]Help triaging git-lfs checkout failure[/+] on Apr 28, 2022
  2. bk2204 commented on Apr 28, 2022

    @bk2204
    Member

    Hey,

    Thanks for reporting this. I think the thing that would be interesting to me is to see the output when it fails with both GIT_TRACE=1 and GIT_TRACE_PACKET=1. This panic indicates that we're getting an entry in the Git filter-process output that doesn't contain a key-value pair. This is easy enough to fix, but it would be useful to know what it is just so we can write a suitable test.

  3. oderby commented on May 2, 2022

    @oderby
    Author

    Hey @bk2204 I've reproduced again with both env vars set. I uploaded the packet output and the offending file to a new gist. Hope that helps!

  4. bk2204 commented on May 2, 2022

    @bk2204
    Member

    Hey,

    Thanks for that information. Unfortunately, it doesn't look like it tells me what the problematic pkt-line is, so I'm just going to have to fix it without writing a test. Could you try #4974 to see if it fixes your issue? CI should build binaries when it's done (which you can grab from the Actions log page) if you need them.

  5. oderby commented on May 3, 2022

    @oderby
    Author

    Okay, with the built binary from #4982, the git-lfs checkout made further progress, but now fails occasionally with a different error :/ gist with full log file output:

    unknown command ""
    error: packet write failed: Broken pipe
    error: external filter 'git-lfs filter-process' failed
    fatal: jane/jane-tiles-cli/fixtures/tiles/10/166/393.full.ndjson: clean filter 'lfs' failed
    
  6. bk2204 commented on May 4, 2022

    @bk2204
    Member

    Hmmm. I can't reproduce the problem from the trace output, and this indicates that we likely have a protocol violation on one end or the other. I know that Git strips out newlines from the trace output, so that isn't entirely unexpected.

    Do you maybe have a repository where you can reproduce this that I could look at? Does it reproduce with a stock version of Git from upstream (or at least a distro package)?

  7. oderby commented on May 10, 2022

    @oderby
    Author

    This dropped off my radar @bk2204, apologies.

    Do you maybe have a repository where you can reproduce this that I could look at?

    Unfortunately I only have it reproducing on a private repo that I can't share.

    Does it reproduce with a stock version of Git from upstream (or at least a distro package)?

    I'm not sure what you mean here - the docker containers this is being run in installs git from ubuntu upstream, so i'd hope that's stock git?

    Separately, the other issue/quesiton that hasn't been discussed yet is why this panic doesn't cause the git lfs checkout command to exit with a non-zero exit code? That is, when this error occurs, git lfs seems to continue happily as if nothing was wrong, but leaves my git index in a dirty state...which was surprising and confusing to me (and caused us to miss this in CI for quite some time since our git lfs checkout job happily finished, despite being in a dirty state)

  8. reopened this on May 10, 2022
  9. bk2204 commented on May 10, 2022

    @bk2204
    Member

    I'm not sure why it's exiting nonzero here because I can't reproduce it, unfortunately. Could you take the code from the debug-filter-process-no-command branch on bk2204/git-lfs, build it, and see if Git LFS logs the error "found unknown request" in the trace output? That would help us figure out what's going on in this case.

  10. oderby commented on May 10, 2022

    @oderby
    Author

    @bk2204 I've built the branch you indicated and the error still reproduces. I do not see any line with the string "found unknown request" in the trace output.

    I'm not sure it's relevant, but I'm noticing that it seems every time git lfs fails, the file being processed is one of several large ndjson formatted files we have in LFS - is it possible that something (hard to imagine what though) related to those files specifically would be causing issues for the LFS client?

  11. oderby commented on May 10, 2022

    @oderby
    Author

    Indeed - if I git rm all the ndjson files from our repo, this issue no longer reproduces. I'm sure it's not ndjson specifically, but that seems like a potential hint as to building a repro case - maybe make a repo with a bunch of copies of these large ndjson files?

  12. bk2204 commented on May 12, 2022

    @bk2204
    Member

    Okay, since we can't seem to reproduce this and trace output doesn't seem to be effective here, I'm going to mark this as need a reproduction case. If we can get a repo that demonstrates the problem, we'll be happy to look into it further.

  13. added
    mcve-required
    on May 12, 2022
  14. artem-sidorenko commented on Jun 23, 2022

    @artem-sidorenko

    @bk2204 it looks like I can reproduce this problem more or less pretty stable. But same for me, it happens in the CI on the private repo I can't share. It looks like a some kind of run-time issue for me - it breaks one of 20 CI runs for us.

    Logs look very similar to the posted above:

    without debug environment variables

    Getting source from Git repository
    Fetching changes...
    Initialized empty Git repository in /builds/XXX/.git/
    Created fresh repository.
    Checking out d5edd147 as master...
    Error updating the git index:
    unknown command ""
    error: packet write failed
    error: external filter 'git-lfs filter-process' failed
    fatal: XXX/XXX.tgz: clean filter 'lfs' failed
    Errors logged to /builds/XXX.git/lfs/logs/20220615T163023.401249194.log
    Use `git lfs logs last` to view the log.
    
    
    $ git lfs logs last
    git-lfs/2.11.0 (GitHub; linux amd64; go 1.13.11; git fceccfb7bd)
    git version 2.26.3
    $ git-lfs pull
    Error updating the git index:
    unknown command ""
    error: packet write failed
    error: external filter 'git-lfs filter-process' failed
    fatal: XXX/XXX.tgz: clean filter 'lfs' failed
    exit status 128
    ...
    

    with debug environment variables GIT_TRACE=1 and GIT_TRANSFER_TRACE=1:

    Getting source from Git repository
    Fetching changes...
    ...
    Initialized empty Git repository in /builds/XXX/.git/
    Created fresh repository.
    Checking out 5cc9f85f as debug...
    ... # tonns of LFS and git debug output
    12:27:24.902168 trace git-lfs: HTTP: 200
    12:27:24.914641 trace git-lfs: xfer: adapter "basic" worker 6 finished job for "f7263dd9c68168304603f3444f8cfeec00ae68eeed711271f4a377f977473d27"
    12:27:24.954942 trace git-lfs: HTTP: 200
    12:27:24.956546 trace git-lfs: xfer: adapter "basic" worker 3 finished job for "6fe82131fb67a6e6b4d9890e97e8315cb9430f5c9c81ffdf534d9eb9123109b7"
    12:27:24.956629 trace git-lfs: xfer: adapter "basic" End()
    12:27:24.956656 trace git-lfs: xfer: adapter "basic" worker 7 stopping
    12:27:24.956668 trace git-lfs: xfer: adapter "basic" worker 3 stopping
    12:27:24.956678 trace git-lfs: xfer: adapter "basic" worker 6 stopping
    12:27:24.956688 trace git-lfs: xfer: adapter "basic" worker 2 stopping
    12:27:24.956700 trace git-lfs: xfer: adapter "basic" worker 0 stopping
    12:27:24.956722 trace git-lfs: xfer: adapter "basic" worker 5 stopping
    12:27:24.956722 trace git-lfs: xfer: adapter "basic" worker 4 stopping
    12:27:24.956753 trace git-lfs: xfer: adapter "basic" worker 1 stopping
    12:27:24.956784 trace git-lfs: xfer: adapter "basic" stopped
    Error updating the git index:
    12:27:24.908803 trace git-lfs: exec: git 'version'
    12:27:24.914487 trace git-lfs: exec: git 'config' '-l'
    12:27:24.917905 trace git-lfs: Install hook: pre-push, force=false, path=/builds/XXX/.git/hooks/pre-push, upgrading...
    12:27:24.918361 trace git-lfs: Install hook: post-checkout, force=false, path=/builds/XXX/.git/hooks/post-checkout, upgrading...
    12:27:24.918624 trace git-lfs: Install hook: post-commit, force=false, path=/builds/XXX/.git/hooks/post-commit, upgrading...
    12:27:24.918856 trace git-lfs: Install hook: post-merge, force=false, path=/builds/XXX/.git/hooks/post-merge, upgrading...
    12:27:24.919070 trace git-lfs: Initialize filter-process
    unknown command ""
    error: packet write failed
    error: external filter 'git-lfs filter-process' failed
    fatal: XXX/XXX.tgz: clean filter 'lfs' failed
    Errors logged to /builds/XXX/.git/lfs/logs/20220622T122724.960335577.log
    Use `git lfs logs last` to view the log.
    

    I'm happy to provide more information and help to investigate it

  15. 51 remaining items

  16. added and removed
    to-investigate
    on Mar 22, 2025
  17. moved this to Bugs in Backlogon Mar 22, 2025
  18. modified the milestones: v3.7.0, on Jun 26, 2025
  19. ravenAtSafe commented on Aug 13, 2025

    @ravenAtSafe

    This sounds like something we are experiencing as well (periodically, maybe increasing in frequency with the number of LFS files, maybe just coming and going)

    1. We run git lfs pull in a Linux CI environment, it returns without indicating any error
    2. We get later build errors about a corrupted zip file which turn out to be because an LFS stub wasn't replaced during the pull

    Strangely it is almost always the same file, despite that file not being anywhere near as large as other LFS files in the repo. 600MB bad vs 1GB fine.

    It's possible that this scenario occurs only after a different LFS problem, where an LFS pull takes so long that Jenkins times it out - possibly that results in a corrupted state that manifests like this in later pulls?

    Update: I'm increasingly convinced that a Jenkins timeout is involved. Sometimes the timeouts result in the checkouts (including lfs pull) being reported as an error and sometimes not despite clearly being logged as an error. This is using the builtin checkout() function in Jenkins, configured to LFS pull as well. So maybe this is on Jenkins rather than git.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    • Status
      Bugs

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions