feat(fetch): add fetch-mode to work around HuggingFace clone failures (bug 2047876) - #1046
Open
JohanLorenzo wants to merge 2 commits into
Open
JohanLorenzo wants to merge 2 commits into
JohanLorenzo wants to merge 2 commits into
Conversation
JohanLorenzo
force-pushed
the
bug-2047876
branch
3 times, most recently
from
September 18, 2026 13:48
986a91f to
e0efb86
Compare
…47876) HuggingFace's git backend answers gzipped git-upload-pack requests with an empty packfile. Git gzips the request once it exceeds 1024 bytes, and a clone sends one "want" per ref, so repos with more than ~18 refs cannot be cloned: Mozilla/smart-tab-topic has 34 and fails with "fatal: expected 'packfile'". The new init_and_fetch mode inits an empty repo and fetches only the requested commit, a ~174 byte request whatever the ref count. It is opt-in; clone remains the default and is unchanged.
Lets a kind opt into fetch-content's init_and_fetch mode for repos whose git server cannot serve a full clone. The flag and its digest entry are only added when the mode is not the default, so existing fetch tasks keep their command and their cached artifacts.
JohanLorenzo
force-pushed
the
bug-2047876
branch
from
September 18, 2026 13:52
e0efb86 to
3f3d42b
Compare
JohanLorenzo
marked this pull request as ready for review
September 18, 2026 14:10
Contributor
What does this have to do with compression? |
Contributor
Author
|
Past 1024B, the git client requests gzip. E.g.: |
Contributor
Author
|
To be more precise, Then, to identify the threshold: cd "$(mktemp -d)"
R=https://huggingface.co/Mozilla/smart-tab-topic
git ls-remote "$R" | awk '{print $1}' | sort -u > oids
for n in 17 18 19 20; do
git init -q "p$n" && git -C "p$n" remote add origin "$R"
printf '%2d wants: ' "$n"
GIT_LFS_SKIP_SMUDGE=1 git -C "p$n" fetch -vv --no-tags origin \
$(head -"$n" oids | tr '\n' ' ') 2>&1 | grep -E 'POST|fatal' | tail -2
doneSo, the HuggingFace git backend doesn't support gzip correctly on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I propose to add
fetch-modeoption togitfetch tasks to workaround the case of HuggingFace. Their backend compresses the request once the uncompressed body exceeds 1024 bytes. Which request? A clone cannot name the references it needs (like branches and tags), which git calls it awantso all of them are requested.As of this writing,
Mozilla/smart-tab-topichas 34 refs (5 branches + 29 tags) which means 1880B.Why not
--depth?The workaround proposed in the bug comments is
git clone -n --depth 100000which is more a band-aid. Fetching the single pinned revision is 174 bytes regardless of how many branches, tags or PR refs the repo accumulates over time.fetch origin <revision>--depth 100000--single-branch, silently narrowing to ancestors of the default-branch tip. The depth number was never the operative part.--depth 1--single-branch4a34f12(tip ofadd-weights) becomes unreachable--no-tagsfetch-modeif a repo needs the clone semantics.--filter=blob:none/tree:0protocol.version=0/1Example usage