Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Fix 404 NOT FOUND issue caused by endpoint tail slash #2721

Merged

Conversation

Mingqi2
Copy link
Contributor

@Mingqi2 Mingqi2 commented Dec 26, 2024

The issue was triggered when user added a tail slash '/' in HF_ENDPOINT, like $set HF_ENDPOINT=https://hf-mirror.com/.

Then it's interesting (stupid?) to visit a link like - https://hf-mirror.com//api/models/sentence-transformers/all-MiniLM-L6-v2/revision/main by huggingface.

Okay then you got 404 and don't know why. Bad experience and you should take care of them in the code with urljoin and carefully strip.

Signed-off-by: Mingqi Hu <mingqi.hu@intel.com>
@Mingqi2
Copy link
Contributor Author

Mingqi2 commented Dec 26, 2024

@Wauplin could you please review this PR? thanks.

Copy link
Contributor

@hanouticelina hanouticelina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Mingqi2, one of the maintainers of huggingface_hub here 👋
thanks a lot for your contribution! indeed, some servers might block double slashes in URLs as they can potentially lead to security vulnerabilities (see this stackoverflow comment for more context). This is not the case for https://huggingface.co but since we also allow custom endpoints, we can handle this case properly with a minimal endpoint normalization!

src/huggingface_hub/constants.py Outdated Show resolved Hide resolved
src/huggingface_hub/constants.py Show resolved Hide resolved
src/huggingface_hub/utils/_http.py Outdated Show resolved Hide resolved
src/huggingface_hub/utils/_http.py Outdated Show resolved Hide resolved
Mingqi2 and others added 3 commits December 31, 2024 20:08
Co-authored-by: Célina <hanouticelina@gmail.com>
Co-authored-by: Célina <hanouticelina@gmail.com>
Co-authored-by: Célina <hanouticelina@gmail.com>
@Mingqi2
Copy link
Contributor Author

Mingqi2 commented Dec 31, 2024

@hanouticelina thanks for your warm reply! I have commited most of your changes. Please take a look again and help to merge it thanks.

@Mingqi2 Mingqi2 requested a review from hanouticelina January 2, 2025 13:55
Copy link
Contributor

@hanouticelina hanouticelina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just noticed a typo in the imports, once it's fixed, we will be good to merge! 🎉

src/huggingface_hub/constants.py Outdated Show resolved Hide resolved
src/huggingface_hub/constants.py Show resolved Hide resolved
Co-authored-by: Célina <hanouticelina@gmail.com>
@Mingqi2
Copy link
Contributor Author

Mingqi2 commented Jan 3, 2025

just noticed a typo in the imports, once it's fixed, we will be good to merge! 🎉

Good catch. It's committed thanks! Let's merge 🎉

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Contributor

@hanouticelina hanouticelina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good! thanks @Mingqi2 for your contribution! 🤗
failing tests are unrelated and will be fixed when #2728 will be merged.

@hanouticelina hanouticelina merged commit 438f2fb into huggingface:main Jan 6, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants