[BUG] Shorthand like git/git or jonas/tig is rejected because rstrip(".git") strips a character set
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
Direzione di ricerca
Il bug è nella chiamata rstrip(".git") sul controllo del componente di percorso in src/apm_cli/models/dependency/reference.py, intorno alla riga 1526; rimuove un insieme di caratteri invece del suffisso. Inizia riproducendo con DependencyReference.parse("git/git") e poi guarda tests/unit/test_generic_git_urls.py. Il lavoro è completo quando i nomi abbreviati composti solo da '.', 'g', 'i', 't' vengono analizzati, owner/..git genera ancora l'errore di traversal e un test parametrizzato copre git, tig, gitit e git.git.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 4.3k
- Fork
- 415
- Merge medio
- 3g 4h
- PR unite (30g)
- 176
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/apm
-
[BUG] Hermes MCP adapter drops cwd, extra passthrough keys and the SSE transport when writing config.yamlForse già presa @Parth-Vasave l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
microsoft/apm#3749 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
compilation-target policy check ignores the plural targets: keyForse già presa @MohammedAlkindi l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
require_pinned_constraint rejects [email protected] release tags as bare branchesForse già presa @MohammedAlkindi l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
type/automation type/performance
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
[BUG] apm compile reports 'Referenced file not found' for links with a #fragmentForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertastatus/accepted
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
microsoft/apm#3255 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di microsoft/apm
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
benchflow-ai/skillsbench#1090 ·
-
Missing unit tests for human-readable date/time formatters in utils/datetime.pyForse già presa @prabhleen2317 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
apache/iceberg-python#4387 ·
I maintainer di solito rispondono entro 1 giorno
-
backend bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NVIDIA/numba-cuda-mlir#467 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
BUG: UserAgentGenerator.generate ignores browser_type and returns a random browser stackForse già presa @HhH666-ux l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno