[BUG] Shorthand like git/git or jonas/tig is rejected because rstrip(".git") strips a character set
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
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
- Check out main at fe6f089.
- Run
DependencyReference.parse("git/git"). Usejonas/tigorowner/gititfor other cases. - 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,tthatrstriphad 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 checkandruff format --checkpass on the 2 changed files.tests/unit/test_generic_git_urls.pygives 213 passed on main and 217 passed with the fix.- A wider run of the 116 unit files that call
DependencyReference.parsegives 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:
- Shorthand names made only of
.,g,i,tnow parse. This matches what the URL form already does. owner/..gitis still rejected. The message changes from "Invalid repository path component" to the traversal message.- 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
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/apm
-
[BUG] Hermes MCP adapter drops cwd, extra passthrough keys and the SSE transport when writing config.yamlPossibly taken @Parth-Vasave claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
microsoft/apm#3749 · 1 comment ·
Maintainers usually reply within 1 day
-
compilation-target policy check ignores the plural targets: keyPossibly taken @MohammedAlkindi claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
require_pinned_constraint rejects [email protected] release tags as bare branchesPossibly taken @MohammedAlkindi claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
type/automation type/performance
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
[BUG] apm compile reports 'Referenced file not found' for links with a #fragmentPossibly taken A pull request linked to this issue is open or already merged. Openstatus/accepted
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
microsoft/apm#3255 · 2 comments ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
benchflow-ai/skillsbench#1090 ·
-
Missing unit tests for human-readable date/time formatters in utils/datetime.pyPossibly taken @prabhleen2317 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
apache/iceberg-python#4387 ·
Maintainers usually reply within 1 day
-
backend bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NVIDIA/numba-cuda-mlir#467 · 1 comment ·
Maintainers usually reply within 3 days
-
BUG: UserAgentGenerator.generate ignores browser_type and returns a random browser stackPossibly taken @HhH666-ux claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day