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

create_repo with exists_ok=True returns 403 with fine-grained token #2955

Closed
lhoestq opened this issue Mar 25, 2025 · 3 comments
Closed

create_repo with exists_ok=True returns 403 with fine-grained token #2955

lhoestq opened this issue Mar 25, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@lhoestq
Copy link
Member

lhoestq commented Mar 25, 2025

Describe the bug

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/huggingface_hub/utils/_http.py", line 409, in hf_raise_for_status
    response.raise_for_status()
  File "/usr/local/lib/python3.11/dist-packages/requests/models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://huggingface.co/api/repos/create

Reproduction

  1. create a model repo on HF
  2. create a fine-grained token with write access to that repo
  3. call create_repo with exist_ok=True using that token

Logs

System info

latest hfh
@lhoestq lhoestq added the bug Something isn't working label Mar 25, 2025
@Wauplin
Copy link
Contributor

Wauplin commented Mar 25, 2025

Can't reproduce the issue 😕

  1. I have https://huggingface.co/Wauplin/my-cool-mamba
  2. Created token with

Image

  1. calling create_repo(..., exist_ok=True) works for me:
>>> from huggingface_hub import create_repo, __version__
>>> token="hf_..."
>>> create_repo("Wauplin/my-cool-mamba", exist_ok=True)
RepoUrl('https://huggingface.co/Wauplin/my-cool-mamba', endpoint='https://huggingface.co', repo_type='model', repo_id='Wauplin/my-cool-mamba')
>>> __version__
'0.30.0.dev0'

@lhoestq
Copy link
Member Author

lhoestq commented Mar 25, 2025

hmm weird, I'll investigate more. On my side it was using trl SFTTrainer with HF_TOKEN environment variable on google colab

@lhoestq
Copy link
Member Author

lhoestq commented Mar 27, 2025

closing for now, I'll check later - sorry for the inconvenience !

@lhoestq lhoestq closed this as completed Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants