Skip to content

HfFileSystem.url() returns a wrong folder URL when the repo id contains 'resolve' #5172

Open

Description

@LemonCondor

Describe the bug

HfFileSystem.url() builds the URL of a directory by replacing the first /resolve/ in the file URL with /tree/. When the namespace or the repo name is literally resolve, that first occurrence is part of the repo id, not the route, so the link points to a different repo.

Reproduction

from huggingface_hub import HfFileSystem
fs = HfFileSystem()
fs.url("my-org/resolve/data")   # "data" is a folder
# -> https://huggingface.co/my-org/tree/resolve/main/data   (wrong)
# expected https://huggingface.co/my-org/resolve/tree/main/data

The same happens for a namespace named resolve (resolve/my-model/folder), for datasets, and for buckets.

Logs

No response

System info

huggingface_hub main (version = "2.3.0.dev0"). The cause is url.replace("/resolve/", "/tree/", 1) in hf_file_system.py. Only rewriting the part after the repo/bucket base URL fixes it. I have a small PR with a regression test ready.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions