Skip to content

LFS Client Error (InvalidArgumentError) #3494

Closed

Description

@rstecca

Hello,
trying to perform a git lfs fetch but it just hangs (0 B/s for a while) and then quit with

LFS: Client error: https://api.media.atlassian.com/file/992a6467-031c-499d-841f-19711e45640d/binary

The command
GIT_TRACE=1 GIT_CURL_VERBOSE=1 git lfs fetch
results in a long series of errors like this one below:

< HTTP/1.1 400 Bad Request < Connection: close < Content-Length: 167 < Access-Control-Allow-Origin: * < Access-Control-Expose-Headers: Accept-Ranges, Content-Encoding, Content-Length, Content-Range < Content-Type: application/json < Date: Thu, 24 Jan 2019 15:14:19 GMT < Strict-Transport-Security: max-age=15552000; includeSubDomains < X-B3-Spanid: 13f3b59a8f95a973 < X-B3-Traceid: 13f3b59a8f95a973 < X-Content-Type-Options: nosniff < X-Dns-Prefetch-Control: off < X-Download-Options: noopen < X-Frame-Options: SAMEORIGIN < X-Xss-Protection: 1; mode=block < 15:14:22.479535 trace git-lfs: HTTP: {"error":{"code":"InvalidArgumentError","title":"range first index must not be greater than last index","href":"https://api.media.atlassian.com#InvalidArgumentError"}} {"error":{"code":"InvalidArgumentError","title":"range first index must not be greater than last index" ,"href":"https://api.media.atlassian.com#InvalidArgumentError"}}15:14:22.479535 trace git-lfs: tq: retr ying object 77dfe7e27990ba66880d64d5423e862b37cb7461405cdc03789e3bf055a050e1: LFS: Client error: https: //api.media.atlassian.com/file/7392df22-bf24-4717-aa21-7efb92efa827/binary 15:14:22.479535 trace git-lfs: tq: enqueue retry #1 for "77dfe7e27990ba66880d64d5423e862b37cb7461405cdc 03789e3bf055a050e1" (size: 122880044) 15:14:22.588244 trace git-lfs: filepathfilter: rewrite ".git" as "**/.git/**" 15:14:22.588244 trace git-lfs: filepathfilter: rewrite "**/.git" as "**/.git" 15:14:22.588244 trace git-lfs: filepathfilter: rejecting "tmp" via [] 15:14:22.588244 trace git-lfs: filepathfilter: accepting "tmp"

I'd put this in evidence as should be relevant:
trace git-lfs: HTTP: {"error":{"code":"InvalidArgumentError","title":"range first index must not be greater than last index","href":"https://api.media.atlassian.com#InvalidArgumentError"}

I suspected the service was down but all operational on the bitbucket status page.
What am I doing wrong?

Activity

  1. bk2204 commented on Jan 24, 2019

    @bk2204
    Member

    Hey, sorry you've having trouble.

    It sounds like what's happened is that one or more of the files you're trying to download are partially downloaded, and for some reason they have more data than they're supposed to. When we download a file, we send a Range header if the file already exists, and the server has complained that the low end of the range is larger than the high end (which is of course nonsensical).

    I have a branch on my remote called retry-on-oversize-file. Can you try it and see if it fixes your problem?

  2. Apo- commented on Jan 25, 2019

    @Apo-

    @rstecca I've been having the same issue since yesterday (repo is also hosted on bitbucket).

    I got this issue when CI was pulling, so then I tried cloning the repo locally, but then I get Encountered <n> file(s) that should have been pointers, but weren't. The git lfs migrate import and git lfs uninstall && git reset --hard didn't work. If I try to lfs pull anyway I get the same error and also Unsolicited response received on idle HTTP channel starting with.

    @bk2204 I don't get what you meant by

    I have a branch on my remote called retry-on-oversize-file. Can you try it and see if it fixes your problem?

  3. bk2204 commented on Jan 25, 2019

    @bk2204
    Member

    @Apo- I have a commit on the branch at https://github.com/bk2204/git-lfs/tree/retry-on-oversize-file which I think will address this bug. If possible, it would be nice if you or @rstecca could compile that branch and see if it fixes the InvalidArgumentError errors that you're seeing. (It won't fix any other errors that you're seeing, though.)

  4. Apo- commented on Jan 28, 2019

    @Apo-

    @bk2204 It didn't do the trick for me, but I'm posting the process I followed in case it solves @rstecca problem (for Ubuntu 18.04):

    # Install go
    # Based on https://www.digitalocean.com/community/tutorials/how-to-install-go-on-ubuntu-18-04
    cd ~
    curl -O https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz
    tar xvf go1.11.5.linux-amd64.tar.gz
    sudo chown -R root:root ./go
    sudo mv go /usr/local
    sudo nvim ~/.profile
    # export GOPATH=$HOME/work
    # export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
    source  ~/.profile
    mkdir $HOME/work
    
    # Build git-lfs
    go get github.com/bk2204/git-lfs
    cd src/github.com/bk2204/git-lfs/
    git checkout retry-on-oversize-file
    nvim Makefile
    # Replaced lint target with
    # .PHONY : lint
    # lint :
    
    # Replace git-lfs
    git lfs uninstall
    sudo mv /usr/bin/git-lfs /usr/bin/git-lfs.old
    sudo mv ~/work/bin/git-lfs /usr/bin
    sudo chown root:root /usr/bin/git-lfs
    git lfs install
  5. alexander-north commented on Jan 29, 2019

    @alexander-north

    I've encountered this exact error - also on Bitbucket with git LFS. I've tried everything I can think of. Increased LFS timeouts, disabled smudge, nothing works.

    In my case it's occurring for 34 different files.

    Updates:

    This issue eventually resolved itself after about 15 painful repeat clones of a 20GB project. Then it came back.

    As per @Apo- 's ticket on https://bitbucket.org/site/master/issues/18064/git-lfs-fetch-fails-with and his workaround there, the following command allows git pulls for LFS projects:

    GIT_LFS_SKIP_SMUDGE=1 git pull

    This, however, ended up causing some significant file corruption, so I wouldn't recommend it.

  6. fraserr commented on Jan 29, 2019

    @fraserr

    Having the same issue also.

  7. MattShaile commented on Jan 29, 2019

    @MattShaile

    I'm also having this problem. I've tried fresh checkouts, reinstalling git, rolling back to an older version of git & lfs (matching a colleagues who is not getting the issue in the same repo) but yet it still occurs, every time, on the same files.
    Since it only happens to me it must be to do with environment, but can't for the life of me figure out what is causing it

    In case the error is slightly different / is helpful in any way, below is git lfs logs last

    git-lfs/2.2.1 (GitHub; windows amd64; go 1.8.3; git 621d1f82)
    git version 2.14.1.windows.1
    
    $ git-lfs.exe filter-process
    2019/01/29 01:34:29 Unsolicited response received on idle HTTP channel starting with "\x81\x81\x80\xfe\x81\xfe\x80\xf9\x81\x00\x80\xf9\x81\xff\x80\xff\x81\xff\x80\x03\x81\x80\x80\x81\xfd\x80\xfd\x81\x04\x80\x81\x80\x80\x81\xfe\x80\xfd\x81\a\x80\x81\x81\x80\x80\u007f\u007f\x80\xe6\u007f\xfd}\x04~\u007f~\u007f~\xfe\u007f\x00l\xfam\bnmmnonoon\xf5o\xfep\xfcq\xffr\xfcq\xfbr\xfas\xfet\x00s\xfet\x00s\xfdt\x00s\xf9u\xfcv\xfeu\x00v\xfdw\xfex\x02wyx\xfey\xfdx\xf6y\x00x\xffy\x01zx\xfez\xffy\x00z\xfcy\xffx\xffy\xfez\x00y\xfez\x05yzyzyz\xf9y\xffx\xffw\x01vu\xfet\x00s\xfar\btuwxxyyzz\xfe{\a|{|{}||}\xf1|\a}\x86\x91\x9d\xa8\xbb\xc1\xc5\xfe\xc4\n²\xa4\x98\x8c\u007fz~~}}\xf7\u007f\xfe\x80\a\x80\u007f\x80\x80\x81\x80\x80|\xfe~\xff}\xff~\x00}\xfc\u007f\xfd~\x0e}~~}}"; err=<nil>
    Error downloading object: assets/layouts/all@3x/game.psd (a0c6947): Smudge error: Error downloading assets/layouts/all@3x/game.psd (a0c694737dabd47cce16d8532fd6c260e76bc6680c5c67fdd45cd4e32bd1d238): Expected OID a0c694737dabd47cce16d8532fd6c260e76bc6680c5c67fdd45cd4e32bd1d238, got fb44b563c02ab341be927fea474ef003a683617b12d47aa1fd622131c8d6ad82 after 110137365 bytes written
    
    Expected OID a0c694737dabd47cce16d8532fd6c260e76bc6680c5c67fdd45cd4e32bd1d238, got fb44b563c02ab341be927fea474ef003a683617b12d47aa1fd622131c8d6ad82 after 110137365 bytes written
    github.com/git-lfs/git-lfs/errors.newWrappedError
            C:/Users/ttaylorr/go/src/github.com/git-lfs/git-lfs/src/github.com/git-lfs/git-lfs/errors/types.go:170: Error downloading assets/layouts/all@3x/game.psd (a0c694737dabd47cce16d8532fd6c260e76bc6680c5c67fdd45cd4e32bd1d238)
    github.com/git-lfs/git-lfs/errors.newWrappedError
            C:/Users/ttaylorr/go/src/github.com/git-lfs/git-lfs/src/github.com/git-lfs/git-lfs/errors/types.go:170: Smudge error
    
    ENV:
    LocalWorkingDir=C:\Users\Matthew\Desktop\three-dragons
    LocalGitDir=C:\Users\Matthew\Desktop\three-dragons\.git
    LocalGitStorageDir=C:\Users\Matthew\Desktop\three-dragons\.git
    LocalMediaDir=C:\Users\Matthew\Desktop\three-dragons\.git\lfs\objects
    LocalReferenceDir=
    TempDir=C:\Users\Matthew\Desktop\three-dragons\.git\lfs\tmp
    ConcurrentTransfers=3
    TusTransfers=false
    BasicTransfersOnly=false
    SkipDownloadErrors=false
    FetchRecentAlways=false
    FetchRecentRefsDays=7
    FetchRecentCommitsDays=0
    FetchRecentRefsIncludeRemotes=true
    PruneOffsetDays=3
    PruneVerifyRemoteAlways=false
    PruneRemoteName=origin
    AccessDownload=basic
    AccessUpload=basic
    DownloadTransfers=basic
    UploadTransfers=basic
    GIT_CONFIG_PARAMETERS='color.branch=false' 'color.diff=false' 'color.status=false' 'diff.mnemonicprefix=false' 'core.quotepath=false'
    GIT_DIR=.git
    GIT_LFS_PATH=C:\Program Files\Git LFS
    GIT_PAGER=cat
    GIT_PREFIX=
    
  8. Apo- commented on Jan 30, 2019

    @Apo-
  9. MattShaile commented on Feb 1, 2019

    @MattShaile

    I contacted bitbucket support and they've fixed the issue for me! Here is their response:

    We have been able to reproduce this issue on our end. We have identified that this issue is triggered by slow network connections at the time of pulling down the LFS files. This leads to a timeout on our backend.
    
    I would like to inform that our team have identified the issue and have deployed a fix in regards to this.
    
  10. bbain commented on Feb 4, 2019

    @bbain

    TL;DR: Trying remove the files in your .git/lfs/incomplete directory and try again.

    I think I have tracked down what is happening here. There was an outage at Atlassian where a % of requests bad corrupted downloads of the correct size.

    When the git-lfs is downloading a file its placed into .git/lfs/incomplete. When git-lfs got enough data (i.e. the file is of the correct size) it detected that the download was bad and returned an error. The problem is that the temporary file of correct size in .git/lfs/incomplete is still there.

    From this point on git lfs fetch or whatever will fail. The git-lfs sees the temporary file and incorrectly assumes that more data is required. It issues a HTTP request with Range header where starting from the temporary filesize + 1. Well, this is invalid because filesize + 1 is beyond the EOF.

    I would assume that:

    1. git-lfs shouldn't try and do a partial download when all the temporary file is the right size (but maybe wrong content).
    2. git-lfs probably should delete temporary files that it detects as corrupted and just try again. Maybe this happens for free if the step 1 is implemented. This could introduce its own loop I guess.

    This is pretty easy to fake:

    1. Create a repo with one LFS file >100MiB (to make things easy).
    2. Start a clone but interrupt it before it completes.
    3. Do a cat /dev/urandom > .git/lfs/incomplete/<file>.tmp. Kill before the tmp file reaches the size of the LFS file.
    4. Do a git lfs pull. Make sure the upstream supports partial downloads. This will fail with an error.
    5. Do a git lfs pull. This will issue HTTP requests with Range past the end of the file.
  11. bk2204 commented on Feb 4, 2019

    @bk2204
    Member

    I think it's certainly fair that we retry if we get the wrong amount of data or would issue an invalid Range request. I believe the proposed branch does that.

    However, I'm not sure retrying when our download has data and it's corrupt is a good idea, since generally our data has come over an HTTPS connection, which verifies its integrity. That's a situation that we would want to produce an error for, which we do. In fact, doing so probably led to Bitbucket noticing that there was a problem.

  12. bbain commented on Feb 4, 2019

    @bbain

    However, I'm not sure retrying when our download has data and it's corrupt is a good idea, since generally our data has come over an HTTPS connection, which verifies its integrity.

    OK. The main problem is that the git-lfs will end up fail loop that a user wont know how to fix. Maybe a message telling users that something is very wrong and here's how to retry (e.g. by deleting this file)?

  13. bk2204 commented on Feb 6, 2019

    @bk2204
    Member

    I think it's fine to delete the file and retry, which is what my branch does in this case. I plan to spend a few minutes verifying this case and writing up some tests, and then submitting it.

  14. rstecca commented on Feb 12, 2019

    @rstecca
    Author

    Thank you all for the responses. This is all very insightful. I also found that the combination Git-lfs + bitbucket + ssh is very problematic in itself and it causes misterious failures (even now that @RustyGames had bitbucket people's support), cul-de-sacs and cryptic errors. It can be difficult to understand what's failing. Recloning through https seems to be the way to avoid some of the snake pits. Not a solution but at least there's one way to not waste hours, days or weeks until ssh support is more solid. I want to switch back to ssh as soon as possible so I'll keep checking here and try @bk2204 's tricks.
    @bbain amazing investigation. Good to keep in mind for future failures.

  15. rstecca commented on Feb 12, 2019

    @rstecca
    Author

    @bk2204

    I think it's fine to delete the file and retry, which is what my branch does in this case. I plan to spend a few minutes verifying this case and writing up some tests, and then submitting it.

    I'm very curious to see what's the minimal failure case here. Can you post it?

    That's a situation that we would want to produce an error for, which we do. In fact, doing so probably led to Bitbucket noticing that there was a problem

    Oh yes please. A meaningful error for this could have saved a lot of time for me. Cool that this post and your efforts escalated to bitbucket!

  16. bk2204 commented on Feb 12, 2019

    @bk2204
    Member

    I've opened #3518 which has a test for this case, which should demonstrate the problem. My hope is that it will make it into Git LFS 2.7.0.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions