dstack icon indicating copy to clipboard operation
dstack copied to clipboard

[Bug]: `dstack init` does not work with self-hosted git repos or lesser-known repo hosting services

Open jvstme opened this issue 1 year ago • 4 comments

Steps to reproduce

  1. Get a git repo from any self-hosted or lesser-known repo hosting system that doesn't use /<user>/<repo>.git URL paths, e.g. self-hosted BitBucket, Pagure, cgit, etc.
    git clone https://pagure.io/pagure.git
    cd pagure
    
  2. Try initializing a remote dstack repo.
    dstack init
    

Actual behaviour

Traceback (most recent call last):
  File "/home/jvstme/git/dstack/dstack/venv/bin/dstack", line 8, in <module>
    sys.exit(main())
  File "/home/jvstme/git/dstack/dstack/src/dstack/_internal/cli/main.py", line 67, in main
    args.func(args)
  File "/home/jvstme/git/dstack/dstack/src/dstack/_internal/cli/commands/init.py", line 57, in _command
    repo = api.repos.load(
  File "/home/jvstme/git/dstack/dstack/src/dstack/api/_public/repos.py", line 146, in load
    repo = RemoteRepo(local_repo_dir=repo_dir)
  File "/home/jvstme/git/dstack/dstack/src/dstack/_internal/core/models/repos/remote.py", line 176, in __init__
    repo_data = RemoteRunRepoData.from_url(self.repo_url, parse_ssh_config=True)
  File "/home/jvstme/git/dstack/dstack/src/dstack/_internal/core/models/repos/remote.py", line 47, in from_url
    data = RemoteRunRepoData(
  File "/home/jvstme/git/dstack/dstack/venv/lib64/python3.8/site-packages/pydantic_duality/__init__.py", line 250, in __new__
    return cls.__request__(*args, **kwargs)
  File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for RemoteRunRepoDataRequest
repo_user_name
  none is not an allowed value (type=type_error.none.not_allowed)

Expected behaviour

The dstack repo is initialized successfully.

dstack version

master

Server logs

No response

Additional information

Possible solution: consider using the repo URL as-is instead of parsing it with giturlparse.

jvstme avatar Apr 10 '24 09:04 jvstme

This issue is stale because it has been open for 30 days with no activity.

peterschmidt85 avatar May 11 '24 01:05 peterschmidt85

This issue was closed because it has been inactive for 14 days since being marked as stale. Please reopen the issue if it is still relevant.

peterschmidt85 avatar May 25 '24 01:05 peterschmidt85

Relevant

jvstme avatar Jun 12 '24 10:06 jvstme

Another case — cannot use URLs with 3+ path parts, e.g. GitLab subgroups. This leads to a different error. URL: https://gitlab.com/deleteme/deleteme/deleteme.git Error:

     raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: /gitlab.com/deleteme/deleteme/deleteme.git/info/refs?service=git-upload-pack (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa765a831f0>: Failed to establish a new connection: [Errno -2] Name or service not known'))

jvstme avatar Jul 01 '24 14:07 jvstme

dstack init now works with almost any HTTPS clone URL.

However, note that some repo hosting systems still won't work with dstack, e.g. if they use an authentication method not supported by dstack. GitHub and GitLab are guaranteed to work.

jvstme avatar Jul 17 '24 18:07 jvstme