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

Fix download from private renamed repo #1999

Merged
merged 3 commits into from
Jan 24, 2024

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Jan 24, 2024

This PR fixes a bug when trying to download a regular file (non-LFS) from a private renamed repo. The problem came from the fact that:

  1. renaming a repo induce a redirect
  2. we were considering that any redirect means that we are downloading from a CDN
  3. when we download from a CDN, we remove the authorization header since the URL is supposed to be signed
  4. when making the actual GET call, the authorization header was not there + the url is not signed because it is still a relative redirect to huggingface.co

=> this PR fixes this issue by keeping the authorization header when the redirected URL is from the same domain

cc @LysandreJik @osanseviero who investigated the bug
cc @coyotte508 @XciD can you please review this PR as well? Just want to make sure I did not break anything (especially when downloading from a Space)

Copy link
Member

@coyotte508 coyotte508 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Awesome!

@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
Member

@osanseviero osanseviero left a comment

Choose a reason for hiding this comment

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

Nice!

@Wauplin
Copy link
Contributor Author

Wauplin commented Jan 24, 2024

Thanks everyone for the quick review!

@Wauplin
Copy link
Contributor Author

Wauplin commented Jan 24, 2024

(failing tests are unrelated, closing this PR)

@Wauplin Wauplin merged commit 7bb8308 into main Jan 24, 2024
13 of 16 checks passed
@Wauplin Wauplin deleted the fix-download-regular-from-private-renamed-repo branch January 24, 2024 15:24
Copy link
Member

@julien-c julien-c left a comment

Choose a reason for hiding this comment

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

Agree with the fix

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.

None yet

7 participants