[BUG] Transitive git+path monorepo dependency fails "not a valid APM package" on 0.29.1+ (regression from 0.29.0)
Describe the bug
apm install fails to resolve a transitive git: + path: dependency when both the top-level package and its dependency are subdirectories ("virtual packages") of the same monorepo, each with their own valid apm.yml. The resolver reports the dependency as invalid against the bare repository root (no path), even though:
- The declared dependency correctly specifies
path: packages/pkg-shared, which does contain a validapm.yml. - The dependency package's own
apm.ymldeclaresdependencies: apm: []— it has no further dependencies of its own that could explain a second resolution attempt.
This worked correctly on 0.29.0 and regressed starting with 0.29.1. It is still broken on the current latest (0.31.0).
To Reproduce
Repo layout (relevant parts) in a monorepo your-org/your-monorepo:
packages/
pkg-a/
apm.yml
pkg-shared/
apm.yml # dependencies: apm: []
packages/pkg-a/apm.yml:
name: 'pkg-a'
version: '1.0.0'
targets:
- 'copilot'
dependencies:
apm:
- git: https://github.com/your-org/your-monorepo
path: packages/pkg-shared
ref: main
Run:
apm install your-org/your-monorepo/packages/pkg-a --target copilot --verbose
Actual result
[>] Resolving your-monorepo-pkg-a...
[>] Resolving your-monorepo-pkg-shared...
Failed to resolve transitive dep your-org/your-monorepo (via your-monorepo-pkg-a > your-monorepo-pkg-shared): Invalid APM package your-org/your-monorepo:
- Not a valid APM package: no apm.yml, SKILL.md, hooks, or plugin structure found in <hash>. Ensure the package has SKILL.md (skill bundle), apm.yml + .apm/ (APM package), or plugin.json (Claude plugin) at its root.
[x] Installation failed with 1 error(s). No install transaction changes were committed.
The error names the bare repo (your-org/your-monorepo, no path segment), not packages/pkg-shared. The sparse checkout itself materializes correctly (perf: subdir .../packages/pkg-shared sparse=packages/pkg-shared), so the failure is specifically in the validation/graph step, not the clone.
Expected behavior
The dependency should resolve using the declared path: packages/pkg-shared and install successfully, exactly as it did on 0.29.0.
Environment
Tested with a clean apm cache clean before each run:
| APM version | Result |
|---|---|
| 0.29.0 | ✅ Works |
| 0.29.1 | ❌ Fails (same signature) |
| 0.30.0 | ❌ Fails (same signature) |
| 0.31.0 (latest) | ❌ Fails (same signature) |
- OS: macOS
- Install method:
pip install apm-cli==<version>, isolated venv per version
Additional context
- I also tried rewriting the dependency using the documented monorepo-sibling sentinel
git: parent(per the manifest schema) instead of the explicit URL. This does not fix the issue on 0.31.0, and it additionally breaks the previously-working 0.29.0 install with the identical error —git: parentappears to expand to the samerepo_url/virtual_pathcoordinates as the explicit form, hitting the same bug. - Related but distinct reports I found while investigating:
- #2912 — "path: dep validates apm.yml at sparse subdir, not repo root" — closed as not-planned/intentional, but describes a different scenario (path pointing at a non-package subdirectory with no manifest of its own). In our case both subdirectories are valid standalone packages.
- #2888 — "skills: subset install fails on 0.29+/0.30" — fixed in 0.31.0 via #2891, but that mechanism is
skills:subset selection, notgit:+path:virtual packages. - #2877 — registry-based transitive dependency resolution bug — unrelated mechanism (registry, not git).
Given the clean version bisection (0.29.0 passes, 0.29.1 fails), a diff between those two tags in the transitive-dependency validation/graph code should narrow this down quickly.
Thanks for the very thorough bug report -- the clean version bisection (0.29.0 works, 0.29.1+ fails, same signature every time since) and the reproduction with concrete apm.yml files make this easy to act on.
Recommendation: this looks like a clear, real regression in transitive git:+path: dependency validation (the resolver appears to validate against the bare repo root instead of the declared path: subdirectory) and is a good candidate for a maintainer to accept for a fix, once someone bisects the 0.29.0 -> 0.29.1 diff in the validation/graph code as you suggested.
One open question for a reviewer: whether the git: parent sentinel regression you found (breaking even the previously-working 0.29.0 case) is the same root cause or a second bug -- worth confirming during investigation so the fix covers both reported symptoms.
This is advisory only; a maintainer will confirm scope and priority before implementation begins.
Generated by Triage Panel · copilot · auto · 64.9 AIC · ⌖ 5.09 AIC · ⊞ 12K · ◷
Dug into this further to answer the open question about whether the git: parent regression is the same root cause or a second bug.
I diffed the installed apm-cli source between 0.29.0 and 0.31.0:
- The entire
git: parentexpansion path —expand_parent_repo_decl(),_inherit_remote_parent_fields(),_remote_parent_eligible()inapm_cli/deps/apm_resolver.py, plus thegit: parentsentinel parsing inapm_cli/models/dependency/reference.py— is byte-for-byte identical between0.29.0and0.31.0. apm_cli/install/package_resolution.pyandapm_cli/deps/dependency_graph.pyare also unchanged (0 diff lines) between the two versions.
Since git: parent fails identically on 0.29.0 (where explicit git:+path: works fine) and on 0.31.0, and the git: parent code itself didn't change between those versions, the git: parent failure can't be explained by the 0.29.0→0.29.1 regression — it looks like a standing, version-independent defect in git: parent, separate from whatever changed to break the explicit form starting at 0.29.1.
Both failure modes converge on the same validator in apm_cli/models/validation.py (the "Not a valid APM package: no apm.yml, SKILL.md..." check), which only reports the error — it doesn't compute the package_path it's handed. So my best guess is a shared root cause one layer up: whatever resolves/materializes the package_path for a transitive virtual-package dependency picks the wrong directory (bare repo root instead of the declared subpath) in both cases, with the explicit-URL form additionally being gated by something that changed between 0.29.0 and 0.29.1 (I wasn't able to isolate that specific diff — apm_cli/install/phases/resolve.py and the host-classification logic in reference.py both changed non-trivially in that range and are the most likely candidates, but confirming which one actually flips the behavior needs a proper bisect across the intermediate 0.29.1 release, which is best done by someone with access to the private commit history between tags).
Hope this narrows the search space for whoever picks this up.
Decision: approve Area: project Scope: Restore correct declared-subdirectory resolution and validation for nested/transitive Git+path monorepo dependencies. Done when: Reproduce the reported version regression before coding; a consumer/parent/child fixture proves the declared package subdirectory resolves and validates correctly, while unrelated dependency resolution and containment behavior are preserved. Out of scope: Unrelated sentinel expansion, a general resolver rewrite, new source formats, or weakening source/destination containment. Review contact: @danielmeppiel
Restore a documented existing dependency workflow rather than requiring consumers to restructure their repositories.
Recorded by Copilot on behalf of @danielmeppiel following the direct product decisions confirmed on 2026-09-30 and explicit authorization to update the issues on 2026-10-01. Daniel separately confirmed that he is the review contact for accepted scopes. This records a human decision, not an autonomous triage recommendation. It does not promise a release, assign implementation, approve a merge, or bypass review.
Hi @danielmeppiel! I'm interested in working on this issue. I'll start by reproducing the 0.29.0 -> 0.29.1 regression and tracing how the declared path is handled during transitive dependency resolution, keeping within the approved scope. Would it be okay for me to take this on?
Quick update: I’ve started reproducing this locally and confirmed the initial two-package fixture doesn’t trigger the regression for me yet. I’ll continue investigating the consumer/parent/child path over the weekend and post an update once I’ve narrowed it down.
Quick update: I tested the explicit git: + path: case with a clean consumer → parent → child fixture, where parent and child are valid subdirectory packages in the same remote monorepo.
I removed apm.lock.yaml, apm_modules, and cleaned the APM cache between runs. I also tested installing the remote parent subdirectory directly.
So far I get:
0.29.0✅ succeeds0.29.1✅ succeeds0.31.0✅ succeeds
The dependency tree is definitely reaching the transitive path (1 direct + 1 transitive deps), so the public reproducer appears to be missing an additional condition needed to trigger the regression.
@jiteshjadav-rogers, if you still have the original failing fixture or repo, could you share any additional manifest/layout/source details that might be relevant?
@danielmeppiel, if there is an internal or preferred repro shape for this accepted scope, I’d be happy to test against that before proceeding with a fix.
Thanks @danielle060821 for trying to reproduce this. The original minimal repro was simplified too far. Our real layout differs in ways that may matter:
- Diamond / shared transitive dependency. One leaf package is reached through several paths: directly from the root, and again through intermediate packages. All of them use the same
git:URL,path:andref: main. - Chain depth of at least 3. The shape is
consumer → pkg-a → pkg-b → pkg-shared, notconsumer → parent → child. - Several
git:+path:entries per manifest.pkg-adeclares 3 sibling dependencies, all on the same repo URL with differentpath:values. - Private repository. The monorepo is private and accessed over HTTPS with credentials. The sparse-checkout fetch and the validation step might use different host or auth handling.
- Packages with a
.apm/directory next toapm.ymlandskills/. The leaf,pkg-shared, hasdependencies: apm: []. - Dependency URL points at the same repo the parent was installed from. The explicit
git:URL in each manifest equals the parent's own source repo. This is the case thatgit: parentis meant to cover.
A fixture that may trigger it, with every package in one repo your-org/your-monorepo:
# packages/pkg-a/apm.yml
dependencies:
apm:
- {git: https://github.com/your-org/your-monorepo, path: packages/pkg-b, ref: main}
- {git: https://github.com/your-org/your-monorepo, path: packages/pkg-shared, ref: main}
# packages/pkg-b/apm.yml
dependencies:
apm:
- {git: https://github.com/your-org/your-monorepo, path: packages/pkg-shared, ref: main}
# packages/pkg-shared/apm.yml
dependencies:
apm: []
Then run apm install your-org/your-monorepo/packages/pkg-a --target copilot --verbose after apm cache clean.
The error always names the bare repo your-org/your-monorepo with no path:. That suggests the deduplication or visited-key for an already-seen (repo_url, ref) loses the virtual_path, so the second encounter of pkg-shared is validated at the repo root. I haven't confirmed this. It would explain why a two-package chain passes and the diamond shape fails.
I can run the fixture above against 0.29.0 and 0.29.1 and report back if that helps.
Decision: approve Area: project Scope: Restore correct declared-subdirectory resolution and validation for nested/transitive Git+path monorepo dependencies. Done when: Reproduce the reported version regression before coding; a consumer/parent/child fixture proves the declared package subdirectory resolves and validates correctly, while unrelated dependency resolution and containment behavior are preserved. Out of scope: Unrelated sentinel expansion, a general resolver rewrite, new source formats, or weakening source/destination containment. Review contact: @danielmeppiel
Formatting-only governance record repair.
Canonical transcription: https://github.com/microsoft/apm/issues/3071#issuecomment-6299894263 Original decision (retained unchanged): https://github.com/microsoft/apm/issues/3071#issuecomment-5929388968
Copilot generated and posted both the linked canonical transcription and this explanation on behalf of @danielmeppiel, under his explicit authorization to normalize these four existing records and his 2026-10-20 instruction permitting AI disclosure and provenance in immediately linked companion comments. These are AI-generated comments, not human-written text. The original decision and its review contact are unchanged.
This changes formatting and disclosure placement only. It does not create or expand product acceptance, scope, acceptance criteria, exclusions or review commitments; assign or transfer contributor ownership; authorize implementation dispatch, PR approval or merge; promise a release; or override any responsible-human withdrawal or later scope decision.
Original explanatory qualifications and provenance (verbatim):
Restore a documented existing dependency workflow rather than requiring consumers to restructure their repositories.
Recorded by Copilot on behalf of @danielmeppiel following the direct product decisions confirmed on 2026-09-30 and explicit authorization to update the issues on 2026-10-01. Daniel separately confirmed that he is the review contact for accepted scopes. This records a human decision, not an autonomous triage recommendation. It does not promise a release, assign implementation, approve a merge, or bypass review.
Existing contributor/reproduction context (unchanged): danielle060821's existing work claim remains unchanged: https://github.com/microsoft/apm/issues/3071#issuecomment-5943978931 . The source record's reproduction-before-coding condition is unchanged; this repair does not claim the regression has been reproduced. The later reporter-supplied reproduction context remains unresolved, not a new acceptance decision: https://github.com/microsoft/apm/issues/3071#issuecomment-6085798398 .
- Diamond / shared transitive dependency. One leaf package is reached through several paths: directly from the root, and again through intermediate packages. All of them use the same
git:URL,path:andref: main. - Chain depth of at least 3. The shape is
consumer -> pkg-a -> pkg-b -> pkg-shared, notconsumer -> parent -> child. - Several
git:+path:entries per manifest.pkg-adeclares 3 sibling dependencies, all on the same repo URL with differentpath:values. - Private repository. The monorepo is private and accessed over HTTPS with credentials. The sparse-checkout fetch and the validation step might use different host or auth handling.
- Packages with a
.apm/directory next toapm.ymlandskills/. The leaf,pkg-shared, hasdependencies: apm: []. - Dependency URL points at the same repo the parent was installed from. The explicit
git:URL in each manifest equals the parent's own source repo. This is the case thatgit: parentis meant to cover.
The full later report, fixture and unconfirmed hypothesis remain at that link. This formatting repair neither interprets those hypotheses nor takes over, assigns or dispatches contributor work.
Generated by Copilot (operator-directed scope-record normalization). This comment is AI-generated and may contain errors.
Reproduced against a private monorepo, with the same signature as reported. apm-cli 0.29.0 installs; 0.29.1 and 0.31.0 fail. The APM_NO_CACHE=1 workaround and the cause below were confirmed on 0.31.0 only. I didn't run 0.30.0 or the 0.29.x → 0.31.0 diff beyond the three versions above.
Real failure. The "bare repo" in the message is just dep_ref.repo_url, which never includes path:. The found in <64-hex> part is a persistent-cache shard directory name. What fails is that the sparse shard for packages/<dep> contains directories but no files, so validate_apm_package finds no apm.yml.
Why it only shows up for private repos with transitive deps. I confirmed the first two steps with instrumentation. The third is my reading of the code.
- For GitHub hosts,
_persistent_cache_checkoutgoes throughtry_with_fallback(unauth_first=True). It retries with credentials only if the first attempt raises. - For the direct dependency there is no cached bare clone yet, so the unauthenticated attempt fails at the network step. The retry carries the token and works.
- For transitive dependencies, the
<shard>__pbare clone (--filter=blob:none) is already cached by then. The unauthenticated attempt gets past the network step, andgit checkout <sha>(cone sparse checkout, blobless) lazy-fetches blobs. That fetch is rejected with a 401, butgit checkoutexits 0 on git 2.33.0 (the version I tested; I didn't test a newer one). The shard is accepted, so no retry with credentials happens.
Evidence from the failing shards
git statusin the shard shows every tracked file in the cone as deleted (D packages/<dep>/apm.yml, root files, and so on), right aftercheckoutreturns.- The checkout environment for the direct dependency contains
http.<repo-url>.extraheader=Authorization: …. The transitive ones contain no Authorization header, andcredential.helper=is blank. git restore -- .in a broken shard, using that same environment, fails withInvalid username or token. Password authentication is not supported.- Disabling parallelism (
APM_RESOLVE_PARALLEL=0,--parallel-downloads 0) and changing the token source (GITHUB_APM_PAT,GITHUB_TOKEN,GH_TOKEN, keychain) make no difference. APM_NO_CACHE=1makes it pass.
Why public repos don't reproduce it. Nothing in the unauthenticated attempt is rejected, so the blob fetch succeeds. I also tested an anonymized local monorepo (diamond, depth 3+, git: parent, warm and cold cache, 12 loops each on 0.29.0 and 0.31.0) and everything passed on all three versions.
Possible fix. After git checkout, in GitCache.get_checkout (cache/git_cache.py), fail if any tracked file was not materialized. That raises, so the existing fallback retries with credentials:
missing = subprocess.run(
[git_exe, *_safe_git_args(), "-C", str(staged), "ls-files", "--deleted"],
capture_output=True, text=True, timeout=60,
env=subprocess_env, stdin=subprocess.DEVNULL, check=True,
)
if missing.stdout.strip():
raise RuntimeError(
f"Incomplete checkout for {_sanitize_url(url)} @ {sha[:12]}: "
"tracked files were not materialized (blob fetch failed; "
"authentication may be required)"
)
With this applied on 0.31.0, the same diamond-shaped install of 4 dependencies passed on both a cold and a warm cache. I haven't run APM's test suite or added a regression test. One would need an auth-required remote, or a mocked remote that rejects blob fetches.
Workaround for now: APM_NO_CACHE=1.