[BUG] Shorthand like git/git or jonas/tig is rejected because rstrip(".git") strips a character set

Open Beginner friendly
#3,715 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
git, python
Domain
cli

Research direction

The bug is the rstrip(".git") call on the path-component check in src/apm_cli/models/dependency/reference.py around line 1526; it strips a character set rather than the suffix. Start by reproducing with DependencyReference.parse("git/git") and then look at tests/unit/test_generic_git_urls.py. Done means shorthand names made only of '.', 'g', 'i', 't' parse, owner/..git still hits the traversal error, and a parametrized test covers git, tig, gitit and git.git.

Written by the indexing model from the issue text.

Description

Describe the bug
DependencyReference.parse rejects shorthand dependencies whose repo or owner name is made only of the characters ., g, i and t. Examples are git/git, jonas/tig, gitgitgadget/git, owner/git and owner/gitit. The error is Invalid repository path component: git.

The cause is src/apm_cli/models/dependency/reference.py line 1526:

if not re.match(allowed_pattern, part.rstrip(".git")):

rstrip takes a set of characters. It does not remove a suffix. So git becomes an empty string and the pattern check fails.

The maintainer already named this cause in a review note on merged PR #437 (2026-03): "The .rstrip('.git') call strips individual chars from the set {'.','g','i','t'} rather than the suffix '.git'. This is pre-existing and not introduced by this PR." I found no issue or PR that followed up, and the line is unchanged on main. I am filing this to add the user impact and offer a fix.

To Reproduce

  1. Check out main at fe6f089.
  2. Run DependencyReference.parse("git/git"). Use jonas/tig or owner/gitit for other cases.
  3. See ValueError: Invalid repository path component: git.

Real repos with these names exist. git/git has 64,288 stars and jonas/tig has 13,379 stars (checked with gh api on 2026-11-13). DependencyReference.parse has 37 call sites in src, including install/package_selection.py and install/validation.py, so apm install and apm.yml entries reach this line.

Expected behavior
Shorthand should behave like the https URL form. https://github.com/git/git already parses on main, because the URL path check has no rstrip.

Proposed fix
Use part.removesuffix(".git") on that line, plus a parametrized test for git, tig, gitit and git.git. It is a one-line change. The 4 new tests fail on main and pass with the fix.

What I checked on a fresh clone of main:

  • A differential run over 115,762 dependency strings found 0 newly rejected inputs, 0 inputs that parse differently and 0 crashes. 7,223 inputs are newly accepted. Each of them was a name made only of ., g, i, t that rstrip had emptied.
  • Against the https URL form as a reference, over 2,728 shorthand and URL pairs, main disagrees on 2,720 and the fix disagrees on 0.
  • ruff check and ruff format --check pass on the 2 changed files.
  • tests/unit/test_generic_git_urls.py gives 213 passed on main and 217 passed with the fix.
  • A wider run of the 116 unit files that call DependencyReference.parse gives 28 failed on both trees with identical failing ids (symlink tests on my Windows machine), and 4,699 passed on main against 4,703 with the fix.
  • Not run: the full suite, the uv CI jobs, the Linux and Windows-compat CI jobs.

Behavior changes the fix would make:

  1. Shorthand names made only of ., g, i, t now parse. This matches what the URL form already does.
  2. owner/..git is still rejected. The message changes from "Invalid repository path component" to the traversal message.
  3. Nothing that parses today is rejected or parsed differently.

Known pre-existing limit, not caused by the fix: on Windows, owner/... gives an install path of apm_modules\owner\.... Win32 drops trailing dots, so that resolves to the owner folder itself. owner/a. collapses to owner\a the same way. The https URL form already accepts these names on main, and shorthand already accepts owner/a.. The fix only lets owner/... through in shorthand as well. I did not check what install, prune or uninstall would do with it, and I did not check whether GitHub allows a repo named .... I am happy to look at that separately if you want.

Environment

  • OS: Windows 11
  • Python Version: 3.14.7
  • APM Version: main at fe6f089 (not a release)
  • VSCode Version: not relevant

Logs

ValueError: Invalid repository path component: git

Additional context
I have the fix and tests ready and will open a PR once a maintainer approves scope here and names a review contact.

Validated with Claude Opus 5.5.

Dominant language
Python
Stars
4.3k
Forks
415
Avg merge
3d 5h
Merged PRs (30d)
172

Getting set up

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.

More from microsoft/apm

All issues in microsoft/apm

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.