Skip to content

fix(deps): parse repository names ending in .git characters - #3767

Merged
Daniel Meppiel (danielmeppiel) merged 9 commits into
mainfrom
danielmeppiel-0361-t4-resolution-captain
Nov 17, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 9 commits into
mainfrom
danielmeppiel-0361-t4-resolution-captain

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Repository names whose last characters are in .git (for example git/git, jonas/tig, owner/gitit) were rejected in shorthand form because part.rstrip(".git") strips a character set, not a suffix. URL-form installs of such repos also wrote an apm.yml entry that could not be parsed back. Before: apm install git/git failed with "Invalid repository path component: git". After: it parses in every form (shorthand, FQDN shorthand, ADO, HTTPS, SCP) and round-trips through apm.yml.

Changes:

  • models/dependency/reference.py: removesuffix(".git") (a bare .git segment is still rejected).
  • marketplace/output_mappers.py: the same bug class, lstrip("./"), removed the leading dot of ./.hidden/... plugin sources under pluginRoot: ./ or .; now removeprefix("./").
  • The canonical final repository validator also rejects a repository name that still ends in .git after the single .git transport suffix is removed (owner/git.git.git, owner/.git.git, encoded git%2Egit.git): such a name was written back to apm.yml as a different repository, and to_clone_url() would fetch the shorter name. GitHub and GitLab do not allow repository names that end in .git.
  • utils/path_security.py + the canonical final repository validator: reject path segments made only of dots (owner/..., including percent-encoded). GitHub already refuses . and .. as repository names; Windows drops trailing dots from names (https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file: "Do not end a file or directory name with a space or a period"), so owner/... would alias apm_modules/owner on disk.
  • New architecture guard contracts-tooling-strip-charset (owner literal-affix-removal): Ruff B005 only flags strip literals with duplicate characters, so it cannot see .git or ./. The guard rejects any multi-character strip/lstrip/rstrip literal under src/apm_cli/ and scripts/ unless it is an allowlisted deliberate character set. Today's inventory: exactly the 3 bug sites fixed here; 12 allowlisted literals.
  • No lockfile or manifest migration: the stripped value only fed a regex match, never a stored identity. The only narrowing is the double-.git case above, which already produced an apm.yml entry naming a different repository.
  • Tests: unit parse + round-trip in every form, the strip-charset guard's own unit tests, and the real-CLI lifecycle tests/integration/test_git_named_repository_lifecycle.py (folded from the 0.36.1 red team).

Co-authored with Goran (@goranai), who reported the bug and proposed the removesuffix fix and test cases. Thank you!

Issue and approved scope

Issue: Fixes #3715

Human scope-approval comment: #3715 (comment)

Completes the issue. Not in scope: consolidating every .git suffix idiom into one helper.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Validation evidence: see the merge-worker update below for the current head. Original evidence (head 564ecf5, base main 2769573):

  • .venv/bin/python -m pytest -p no:xdist -q tests/unit/models/test_dependency_reference_git_suffix.py tests/unit/marketplace/test_builder_security.py -> 27 passed. On pre-fix src/ the same command -> 11 failed (all .git-character names, URL-form all-dot names, the round-trip property, both ./.hidden cases).
  • .venv/bin/python -m pytest -p no:xdist -q tests/integration/test_architecture_owner_rule_mutations.py -k "tooling-strip or covers_every or deterministic or report_nothing" -> 6 passed (mutation removesuffix -> rstrip is caught).
  • .venv/bin/python -m pytest -p no:xdist -q tests/unit/scripts/test_architecture_runner.py -> 72 passed.
  • Regression: .venv/bin/python -m pytest -p no:xdist -q tests/unit/test_generic_git_urls.py tests/unit/test_path_security.py tests/unit/test_reference_registry_shorthand.py tests/unit/marketplace/ tests/unit/models/ -> 2325 passed, 17 xfailed.
  • Lint: uvx [email protected] check and format --check (src, tests, architecture linter) -> clean; pylint R0801 -> 10.00/10; bash scripts/lint-auth-signals.sh -> clean; python scripts/lint_architecture_boundaries.py --root . -> exit 0.

Spec conformance (OpenAPM v0.1)

  • Spec edit: docs/src/content/docs/specs/openapm-v0.1.md updated
    (new/changed <a id="req-XXX"></a> anchor + prose + Appendix C
    row).
  • Manifest edit: docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.yml
    updated.
  • Test edit: a @pytest.mark.req("req-XXX") test under
    tests/spec_conformance/ added or extended.
  • CONFORMANCE.{md,json} regenerated via
    uv run --extra dev python -m tests.spec_conformance.gen_statement
    and committed.
  • N/A -- this PR does not change OpenAPM-observable behaviour.

`part.rstrip(".git")` stripped a character set, so repository names
such as git/git, jonas/tig or owner/gitit were emptied and rejected in
shorthand form, and URL-form installs persisted an unparseable apm.yml
entry. Use removesuffix, and fix the same bug class in marketplace
pluginRoot subtraction (`lstrip("./")` ate the dot of ./.hidden).

Reject repository path segments made only of dots in the canonical
final validator: Windows drops trailing dots, so `owner/...` would alias
its owner directory on disk.

Add the contracts-tooling-strip-charset architecture guard (Ruff B005
cannot see unique-character literals) with an allowlist of deliberate
character sets, a MutationCase, and a parse/serialize round-trip
property test.

apm-spec-waiver: parser bug fix restoring accepted repository names; no spec requirement changes

Co-authored-by: goranai <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 17, 2026 15:09
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.36.1 milestone Nov 17, 2026
Co-authored-by: goranai <[email protected]>
Co-authored-by: Copilot App <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Accepted repository references do not round-trip safely through manifest serialization, potentially causing later installs to target a different repository or reject the saved reference.

1 open issue
What changed in this PR

Addresses #3715 by correcting literal suffix handling in dependency parsing and prefix handling in marketplace paths. It also adds all-dot repository path validation and regression guards against character-set stripping mistakes.

Changes:

  • Accepts repository names such as git/git and jonas/tig, with parsing and manifest round-trip tests.
  • Preserves hidden plugin source paths and rejects repository segments made entirely of dots.
  • Registers an architecture guard for multi-character strip literals, with mutation coverage.
File Description
tests/​unit/​scripts/​test_architecture_runner.py Adds the new guard to the expected rule inventory.
tests/​unit/​models/​test_dependency_reference_git_suffix.py Tests repository names, all-dot rejection, and manifest round-trips.
tests/​unit/​marketplace/​test_builder_security.py Tests preservation of hidden plugin paths.
tests/​integration/​test_architecture_owner_rule_mutations.py Adds a mutation that restores the faulty suffix stripping.
src/​apm_cli/​utils/​path_security.py Adds optional all-dot segment rejection.
src/​apm_cli/​models/​dependency/​reference.py Uses literal suffix removal and enables all-dot validation.
src/​apm_cli/​marketplace/​output_mappers.py Removes only the literal ./ prefix.
scripts/​architecture_linter/​checks/​contracts_test_taxonomy.py Registers the strip-literal guard.
scripts/​architecture_linter/​checks/​contracts_strip_charset.py Detects multi-character strip literals outside an allowlist.
CHANGELOG.md Documents the parsing and marketplace fixes.
.apm/​architecture/​owners/​contracts-tooling.json Registers ownership and guard metadata for literal affix removal.

Review effort: Balanced

@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_with_followups

Fixes .git-character repo name parsing (community bug #3715 by Goran (@goranai)) with removesuffix, all-dots rejection, and a repo-wide AST strip-charset guard.

panel-mode=lean; personas=supply-chain-security-expert,python-architect,test-coverage-expert,apm-ceo

cc Sergio Sisternes (@sergio-sisternes-epam) -- a fresh advisory pass is ready for your review.

All three panelists converge: the code change is sound. Supply-chain-security confirms no identity confusion or path-aliasing regression: every parse path funnels through the final repository validator with reject_all_dots=True, and the architecture lint closes the strip-charset bug class going forward. Python-architect finds the AST guard, owner registry entry, MutationCase and rule wiring clean, with no selector collision or split authority (reference.py is already a selector of dependency-identity-materialization, so it is correctly named in owner text only). Test-coverage-expert confirms the parametrized suite traps the core parsing fix, but flags two regression-trap gaps.

The first gap traps a Done-when item directly: the parametrized parse test asserts repo_url but does not round-trip through to_apm_yml_entry for shorthand, FQDN, ADO and SCP forms, although the scope record requires parse-and-round-trip. The code round-trips today; the missing piece is the automated guardrail. The second gap: the strip-charset guard has no direct unit tests for allowlist pass-through, bytes-literal detection or scripts/ scope scanning; the MutationCase proves only the target mutation.

This is the kind of community-reported, architecture-hardening fix APM should ship quickly: it widens parsing without migration cost, credits the reporter, and installs a guard that makes the bug class hard to reintroduce. Neither follow-up is a code defect.

Aligned with: Portable by manifest: repo names parse identically across FQDN, ADO, SCP and shorthand forms. Secure by default: all-dot segments are rejected at the canonical validator. Governed by policy: new owner decision literal-affix-removal with guard contracts-tooling-strip-charset and a MutationCase. OSS community driven: closes community-reported #3715 with the reporter as co-author.

Panel summary

Persona B R N Takeaway
Supply Chain Security Expert 0 0 0 removesuffix fix and all-dots rejection are sound; all parse paths converge at the final validator; the lint closes the bug class; no identity confusion or path-aliasing regressions.
Python Architect 0 0 0 AST guard, owner registry entry, MutationCase and rule wiring are sound; no selector collision, no false-negative gap, no split authority.
Test Coverage Expert 0 2 0 Parse regression traps are strong; round-trip through apm.yml is unasserted for non-HTTPS forms despite Done-when requiring it.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Top 2 follow-ups

  1. [Test Coverage Expert] Add a round-trip assertion (parse -> to_apm_yml_entry -> re-parse) for shorthand, FQDN, ADO and SCP forms in test_names_ending_in_git_characters_parse. -- Directly traps a Done-when item; the hypothesis round-trip covers HTTPS only.
  2. [Test Coverage Expert] Add tests/unit/scripts/test_contracts_strip_charset.py covering allowlist pass-through, bytes-literal flagging and scripts/ scope scanning. -- The MutationCase proves the guard fires for the target mutation, but allowlisted literals, bytes constants and the scripts/ tree are untrapped.

Recommendation

The code is correct per all three specialists and the author's targeted, mutation and regression validation. Fold the two test-coverage follow-ups in-PR (both are inside the approved scope and mechanical): round-trip assertion first, guard unit tests second.


Full per-persona findings

Python Architect

No findings.

Supply Chain Security Expert

No findings.

Test Coverage Expert

  • [recommended] Parametrized parse test does not assert round-trip through to_apm_yml_entry for shorthand, FQDN, ADO and SCP forms at tests/unit/models/test_dependency_reference_git_suffix.py:38
    Done-when requires the six names to parse AND round-trip through apm.yml. The hypothesis round-trip is https-only; the parametrized test only asserts repo_url.
    Suggested: Extend the parametrized test to re-parse to_apm_yml_entry() and assert repo_url/host stability.
    Proof (passed): tests/unit/models/test_dependency_reference_git_suffix.py::test_names_ending_in_git_characters_parse -- proves: names ending in .git characters parse in every form, but round-trip is not asserted for non-HTTPS forms. [portability-by-manifest,devx]
  • [recommended] Strip-charset AST guard has no direct unit tests for allowlist pass-through, bytes literals or scripts/ scope scanning at scripts/architecture_linter/checks/contracts_strip_charset.py
    The MutationCase proves the guard fires for removesuffix -> rstrip in src/apm_cli/, but allowlist pass-through, bytes violations and the scripts/ prefix are untrapped.
    Suggested: Add unit cases: single-char ok, allowlisted [] ok, .git flagged, b".git" flagged, scripts/ path scanned.
    Proof (missing at): tests/unit/scripts/test_contracts_strip_charset.py -- proves: allowlisted multi-char strip literals pass while non-allowlisted ones (incl. bytes, scripts/) are flagged. [governed-by-policy,secure-by-default]

This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.


Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.

@goranai

Copy link
Copy Markdown
Contributor

Thanks for taking this forward and for the credit. I checked out af1e695 and it looks good to me.

  • git/git, jonas/tig, owner/gitit and https://github.com/git/git.git all parse and round-trip through to_apm_yml_entry() and back to the same repo.
  • The new test files pass here (27 passed, Windows, Python 3.12).
  • The remaining multi-char strips in src/ are gone. What is left is single-character rstrip(".") / lstrip("."), which the guard rightly ignores.

The Copilot note reproduces: owner/git.git.git parses to owner/git.git, the saved entry owner/git.git reparses as owner/git, and owner/.git.git saves as owner/.git, which is then rejected. It only hits repo names that themselves end in .git. I think GitHub doesn't allow those, so rejecting a name that still ends in .git after the one suffix is removed seems simpler than trying to keep it in the manifest. Either way it isn't something I'd block on.

Parsing removes exactly one ".git" transport suffix. A name such as
owner/git.git.git therefore became owner/git.git, whose apm.yml entry
reparsed as owner/git (and to_clone_url fetched owner/git), and
owner/.git.git serialized to the rejected owner/.git. The canonical
final repository validator now rejects a repository name that still ends
in ".git", for every form (shorthand, FQDN, HTTPS, SCP, ADO).

Also traps the remaining Done-when items: the parametrized cases now
round-trip through to_apm_yml_entry in every form, and the
strip-charset guard gets direct unit tests (allowlist pass-through,
bytes literals, src/apm_cli/ and scripts/ scope, tests/ excluded).

Addresses Copilot inline on src/apm_cli/models/dependency/reference.py:1526
and panel follow-ups 1-2 on #3767.

apm-spec-waiver: dependency-reference parsing fix with no OpenAPM requirement change

Co-authored-by: goranai <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Adds the RT4 real-CLI lifecycle for repository names that end in git
letters (install, manifest replay, audit, uninstall across GitHub,
GitLab FQDN, ADO and URL forms; older bricked manifests; dot-only and
double .git names rejected without writes; marketplace ./.hidden
sources) with its SkillSelectionWorld helper.

The final-name check now decodes the non-ADO segment with
path_security.decode_url_path_segments instead of a raw unquote
(transport-platform-url-path-security), so an encoded
owner/git%2Egit.git is rejected too.

apm-spec-waiver: dependency-reference parsing fix with no OpenAPM requirement change

Co-authored-by: goranai <[email protected]>
Co-authored-by: Copilot App <[email protected]>
@danielmeppiel

Daniel Meppiel (danielmeppiel) commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_now

Delta clears all prior follow-ups: the double .git round-trip break is fixed by rejection and trapped at unit and real-CLI tiers, with CI green and reporter concurrence.

panel-mode=delta; personas=supply-chain-security-expert,test-coverage-expert,apm-ceo

cc Sergio Sisternes (@sergio-sisternes-epam) -- a fresh advisory pass is ready for your review.

Delta since the last advisory (head af1e695):

  • The Copilot inline finding is resolved. owner/git.git.git parsed to owner/git.git, whose apm.yml entry reparsed as owner/git. The canonical final validator now rejects a repository name that still ends in .git once the single .git suffix is removed. This covers every form: shorthand, FQDN, HTTPS (including encoded git%2Egit.git), SCP and ADO. Reporter Goran (@goranai) independently agreed that rejecting is simpler than preserving the extra suffix.
  • Both prior test-coverage follow-ups are folded: round-trip assertions in every form, and direct unit tests for the strip-charset guard (allowlist, bytes, scripts/ scope).
  • The red-team real-CLI lifecycle tests/integration/test_git_named_repository_lifecycle.py is folded in. It covers install/replay/audit/uninstall for seven name forms, a manifest from an older release, and rejected names with no writes.

Both delta panelists return zero findings. Supply chain confirms that rejection is the correct identity-safety call: to_clone_url() does not append .git, so a canonical owner/git.git would have fetched owner/git. GitHub and GitLab do not allow repository names that end in .git, so no legitimate identity is lost. Test coverage confirms the new rejection is trapped at unit and real-CLI tiers, and the lifecycle test is hermetic. The CHANGELOG bullet and PR body now state this narrowing.

Aligned with: Secure by default: the identity-vs-content mismatch is closed at parse time for every form. Portable by manifest: parse, to_apm_yml_entry, and parse again round-trip for shorthand, FQDN, ADO, HTTPS and SCP. Governed by policy: the strip-charset guard has its own unit tests and MutationCase.

Panel summary

Persona B R N Takeaway
Supply Chain Security Expert 0 0 0 Reject-on-residual-.git is the correct identity-safety primitive; encoded, ADO and all parse forms covered; no lockfile breakage risk.
Test Coverage Expert 0 0 0 Both prior follow-ups trapped; double-.git rejection covered at unit and real-CLI tiers; lifecycle test hermetic and meaningful.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Recommendation

All prior follow-ups are folded and verified, both panelists return zero findings, CI is green at d43dae2 (5d87627 plus a clean merge of main), and the reporter agrees with the rejection approach. No remaining items to track; merge at maintainer discretion.

Folded in this run

  • (copilot) Reject repository names that still end in .git once the single .git suffix is removed, in the canonical final validator for every form (encoded names are decoded with the path_security decoder) -- resolved in 2be567b, 8b874d0.
  • (panel) Round-trip parse -> to_apm_yml_entry -> parse asserted for shorthand, FQDN, ADO, HTTPS and SCP -- resolved in 2be567b.
  • (panel) Direct unit tests for the strip-charset guard -- resolved in 2be567b.
  • (captain) Red-team real-CLI lifecycle folded, plus an owner/git.git.git rejection case; CHANGELOG states the narrowing -- resolved in 8b874d0, 5d87627.

Copilot signals reviewed

  • src/apm_cli/models/dependency/reference.py:1526 -- LEGIT: round-trip is a Done-when item; fixed by rejection because to_clone_url() does not append .git (resolved in 2be567b). Thread resolved.

Regression-trap evidence (mutation-break gate)

  • tests/unit/models/test_dependency_reference_git_suffix.py -- deleted the final-name .git reject calls; 6 cases FAILED as expected; guard restored.
  • tests/unit/scripts/test_contracts_strip_charset.py -- deleted scripts/ from the scan scope, then bytes support; each FAILED as expected; guard restored.
  • tests/integration/test_architecture_owner_rule_mutations.py -- MutationCase removesuffix(".git") -> rstrip(".git") is caught by contracts-tooling-strip-charset.

Lint contract

At d43dae2: uvx [email protected] check and format --check silent; pylint R0801 10.00/10; scripts/lint-auth-signals.sh clean; bash scripts/lint-architecture-boundaries.sh exit 0.

CI

All checks green at d43dae2: CI, Merge Gate, Spec conformance, CodeQL, NOTICE Drift. One CI fix iteration: Windows Native Symlink Acceptance failed at 5d87627 during runner profile cleanup (infra); the rerun was green.

Mergeability status

PR head SHA CEO stance iters folds defers Copilot rounds CI mergeable mergeStateStatus notes
#3767 d43dae2 ship_now 1 4 0 2 green MERGEABLE BLOCKED pending required review

Full per-persona findings

Supply Chain Security Expert

No findings.

Test Coverage Expert

No findings.

This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.


Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors.

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 82f8047 into main Nov 17, 2026
24 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-0361-t4-resolution-captain branch November 17, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants