python-poetry / python-poetry/poetry

Poetry cannot add ssh urls from Azure Devops due to their URL

Open
#2,703 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/vcs kind/bug
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

Issue

When running a command to add an SSH link to an Azure DevOps private repo, poetry cannot parse their SSH urls because they are very weird and have port-like identifiers that aren't ports in them.

For example something like this:
poetry add git+ssh://git@ssh.dev.azure.com:v3/[CompanyName]/[Project Name]/[Repo Name] -vvv

I also found it will fail if the path includes urlencoded elements, such as something like this:
poetry add git+ssh://git@ssh.dev.azure.com:v3/MyCompany/My%20Project/some-random-repo

 ~/poetry-test  poetry add git+ssh://git@ssh.dev.azure.com:v3/[CompanyName]/[ProjectName]/[repo-name] -vvv
Using virtualenv: /home/bryanwolf/.cache/pypoetry/virtualenvs/poetry-test-VRaqNbsu-py3.8

[CalledProcessError]
Command '['git', '--git-dir', '/tmp/pypoetry-[repo-name]uas8kco8/.git', '--work-tree', '/tmp/pypoetry-git-[repo-name]uas8kco8', 'checkout', 'ssh.dev.azure.com:v3/[CompanyName]/[ProjectName]/[repo-name]']' returned non-zero exit status 1.

Traceback (most recent call last):
  File "/home/bryanwolf/.poetry/lib/poetry/_vendor/py3.8/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/home/bryanwolf/.poetry/lib/poetry/_vendor/py3.8/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/home/bryanwolf/.poetry/lib/poetry/_vendor/py3.8/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/home/bryanwolf/.poetry/lib/poetry/_vendor/py3.8/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/home/bryanwolf/.poetry/lib/poetry/console/commands/add.py", line 95, in handle
    requirements = self._determine_requirements(
  File "/home/bryanwolf/.poetry/lib/poetry/console/commands/init.py", line 293, in _determine_requirements
    requires = self._parse_requirements(requires)
  File "/home/bryanwolf/.poetry/lib/poetry/console/commands/init.py", line 380, in _parse_requirements
    package = Provider.get_package_from_vcs(
  File "/home/bryanwolf/.poetry/lib/poetry/puzzle/provider.py", line 207, in get_package_from_vcs
    git.checkout(reference, tmp_dir)
  File "/home/bryanwolf/.poetry/lib/poetry/vcs/git.py", line 217, in checkout
    return self.run(*args)
  File "/home/bryanwolf/.poetry/lib/poetry/vcs/git.py", line 284, in run
    subprocess.check_output(["git"] + list(args), stderr=subprocess.STDOUT)
  File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/home/bryanwolf/.poetry/lib/poetry/utils/_compat.py", line 205, in run
    raise CalledProcessError(

I think maybe this could be fixed by changing the pattern_formats by adding [v|V]? to port and % to path?

pattern_formats = {
    "protocol": r"\w+",
    "user": r"[a-zA-Z0-9_.-]+",
    "resource": r"[a-zA-Z0-9_.-]+",
    "port": r"[v|V]?\d+",
    "path": r"[\w~.\-/\\%]+",
    "name": r"[\w~.\-]+",
    "rev": r"[^@#]+",
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in poetry/vcs/git.py, especially the URL pattern_formats shown in the issue, and reproduce the failure with the provided poetry add git+ssh command. Done means Azure DevOps SSH URLs, including encoded path elements and the v3 identifier, are parsed correctly and the repository checkout succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.