[Bug]: Revision-pinned HF downloads can falsely report intact files as corrupted
Maintainers usually reply within 4 days
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 82/100
Research direction
Start with ModelManagement.download_files_from_huggingface in fastembed/common/model_management.py and trace how the revision is passed to model_info, list_repo_tree, and snapshot_download. Use the offline reproduction and the four regression cases named in the issue to check release tags, explicit SHAs, and moving refs. Done means metadata and downloaded files resolve to the same commit and the targeted offline tests pass.
Written by the indexing model from the issue text.
Description
[Bug]: Revision-pinned HF downloads can falsely report intact files as corrupted
What happened?
Reproduced at f91d9168c0291daeafb0a54cebc7c5b4b83f312f (FastEmbed 0.9.1): ModelManagement.download_files_from_huggingface(..., revision="release-v1") passes the existing revision option to snapshot_download but not to the preceding model_info request. Metadata therefore describes main while the downloaded files describe the requested release. A file-size change makes the real local integrity check reject an intact pinned snapshot.
The same consistency problem can happen when a default/named branch moves between metadata resolution and download. I reproduced that race with simulated responses; I am not claiming to have observed a live repository move during a download.
This concerns the online path. #798 addresses a different offline-cache validation path, and the merged #780 limits metadata collection to the downloaded snapshot but still obtains metadata from main.
Expected behavior
Use the requested revision for metadata, then download the exact resolved commit so metadata and files belong to the same snapshot.
Offline reproduction
The three external Hub responses below are mocked. Tiny local file writes, metadata collection, and integrity checks are real. No model download, inference, GPU, or credentials are required beyond installing FastEmbed's normal runtime dependencies.
"""Offline reproduction: Hub responses are simulated; local file verification is real."""
from pathlib import Path
from tempfile import TemporaryDirectory
from types import SimpleNamespace
from unittest.mock import patch
from huggingface_hub.hf_api import RepoFile
from fastembed.common import model_management
from fastembed.common.model_management import ModelManagement
OLD, MAIN = "a" * 40, "b" * 40
FILES = {OLD: b"old model fixture", MAIN: b"new model fixture with a different size"}
with TemporaryDirectory() as cache:
def model_info(repo_id, revision=None, **kwargs):
commit = OLD if revision in ("release-v1", OLD) else MAIN
print(f"model_info: revision={revision!r}, commit={commit}")
return SimpleNamespace(sha=commit)
def list_repo_tree(repo_id, revision, **kwargs):
print(f"list_repo_tree: commit={revision}")
return [RepoFile(path="model.onnx", size=len(FILES[revision]), oid=revision)]
def snapshot_download(revision=None, **kwargs):
commit = OLD if revision in ("release-v1", OLD) else MAIN
print(f"snapshot_download: revision={revision!r}, commit={commit}")
model_file = Path(cache) / "models--qdrant--fixture" / "snapshots" / commit / "model.onnx"
model_file.parent.mkdir(parents=True)
model_file.write_bytes(FILES[commit])
return str(model_file.parent)
with (
patch.object(model_management, "model_info", model_info),
patch.object(model_management, "list_repo_tree", list_repo_tree),
patch.object(model_management, "snapshot_download", snapshot_download),
):
try:
result = ModelManagement.download_files_from_huggingface(
"qdrant/fixture",
cache_dir=cache,
extra_patterns=["model.onnx"],
revision="release-v1",
)
print("Valid pinned snapshot accepted:", Path(result).name == OLD)
except ValueError as exc:
print(type(exc).__name__ + ":", exc)
On the unpatched source:
model_info: revision=None, commit=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
list_repo_tree: commit=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
snapshot_download: revision='release-v1', commit=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
ValueError: Files have been corrupted during downloading process. Please check your internet connection and try again.
Validation and environment
Python 3.11.13 / macOS arm64, FastEmbed source main at the commit above, huggingface-hub 2.2.0, pytest 9.1.1. Four new offline regressions (release tag, explicit SHA, default ref movement, named ref movement) all fail on the base with this false corruption error. Resolving the requested revision and pinning the download to its returned SHA makes them pass; the targeted cache/common suite passed all 15 cases with HF_HUB_OFFLINE=1. Adding the existing tokenizer-fixture suite under offline/empty-cache conditions produces 39 setup errors because its fixture initializes BAAI/bge-small-en-v1.5; it is excluded from this offline acceptance set. Full model-download/inference and platform-matrix tests were not run.
Prepared with OpenAI Codex assistance; the reproduction and stated checks were executed locally.
- Dominant language
- Python
- Stars
- 3.3k
- Forks
- 314
- Avg merge
- 5d 7h
- Merged PRs (30d)
- 23
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from qdrant/fastembed
-
[Bug]: Bm25 splits Tamil, Hindi, Sinhala and other words on their combining marksPossibly taken @Nipuna-Lakruwan claimed this 12 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 30/100
qdrant/fastembed#886 · 2 comments ·
Maintainers usually reply within 4 days
-
miniCOIL clean_words mutates input and loses counts when normalized words collidePossibly taken @pear1-pea claimed this 20 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 1/100
Maintainers usually reply within 4 days
-
[Bug]: URL-backed custom models with the same basename reuse the wrong cached modelPossibly taken @rtmalikian claimed this 24 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 25/100
Maintainers usually reply within 4 days
-
[Bug]: rerank_pairs raises TypeError when pairs are passed as a tuple of pairsPossibly taken @michaelkillgta claimed this 53 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 22/100
Maintainers usually reply within 4 days
-
[Feature]: Support huggingface-hub 2.0May be free again @joein claimed this 63 days ago, and no pull request is open. Open
Difficulty 3/5 1-2 days Newbie friendliness 65/100
qdrant/fastembed#742 · 1 assignee ·
Maintainers usually reply within 4 days
All issues in qdrant/fastembed
Similar issues
-
accepted
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
future-agi/future-agi#5274 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
GenericMappingTools/pygmt#5014 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
w3c/feedvalidator#204 ·
-
[BUG][Low–Medium] founder_numbers.py silently reads a SAFE discount or pool target given as a fraction (0.2) as 0.2%Possibly taken @sumitkhond111-del claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bmad-code-org/BMAD-METHOD#3358 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
open-mmlab/mmcv#3352 ·