Skip to content

dagshub.init(url=...) with trailing slash sets repo_name="" and repo_owner to the wrong segment #701

Description

@chirag127

Problem

dagshub.init(url="https://dagshub.com/<owner>/<repo>/") (trailing slash, as copy-pasted from a browser address bar) silently produces repo_owner="<repo>" and repo_name="", then calls RepoAPI("<repo>/") and create_repo("", ...) on the not-found branch.

Cite

dagshub/common/init.py lines 76-79:

if url.endswith(".git"):
    url = url[:-4]
parts = url.split("/")
repo_owner, repo_name = parts[-2], parts[-1]

No strip of trailing /, no length/emptiness check.

Steps

url = "https://dagshub.com/owner/repo/"
if url.endswith(".git"): url = url[:-4]
parts = url.split("/")
repo_owner, repo_name = parts[-2], parts[-1]
print(repr(repo_owner), repr(repo_name))

Expected

'owner' 'repo'

Actual

'repo' ''

Environment

  • dagshub 0.7.0 (dagshub/__init__.py)
  • Python >=3.9 (setup.py)
  • OS-independent

Fix: strip trailing / before split, and raise if not repo_owner or not repo_name.

Thanks for maintaining DagsHub/client!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions