ISSUE DESCRIPTION [BUG] apm install fail second time with Content hash mismatch Describe…
- User
ISSUE DESCRIPTION
[BUG] apm install fail second time with Content hash mismatch Describe the bug I can install my repo (see apm.yml further down) via
apm install <org>/<repo>/package/<project>just fine (kinda, see the logs, it looks wonky but maybe it's just a new feature) but the second time I runapm installit will fail consistently withContent hash mismatch.To Reproduce Steps to reproduce the behavior:
- apm install <repo>
- apm install
Expected behavior A clear and concise description of what you expected to happen.
Environment (please complete the following information):
- OS: Windows
- APM Version: 0.16.0
Logs
> apm install --update --force [>] Installing dependencies from apm.yml... [>] Resolving github-copilot-agent-skills-testing... [i] Targets: copilot (source: apm.yml) Partial clone (--filter=blob:none) failed for https://dev.azure.com/<org>/tools; retrying with full bare clone. Server may not support filter v2. [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/packages/<project> #default @d479f42e |-- (files unchanged) Partial clone (--filter=blob:none) failed for https://dev.azure.com/<org>/tools; retrying with full bare clone. Server may not support filter v2. [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/packages/myorg #default @d479f42e |-- (files unchanged) [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/instructions/testing.instructions.md #main |-- 1 instruction(s) integrated -> .github/instructions/ Partial clone (--filter=blob:none) failed for https://dev.azure.com/<org>/tools; retrying with full bare clone. Server may not support filter v2. [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/skills/run-coverage #default @d479f42e |-- (files unchanged) Partial clone (--filter=blob:none) failed for https://dev.azure.com/<org>/tools; retrying with full bare clone. Server may not support filter v2. [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/skills/update-from-template #default @d479f42e |-- (files unchanged) Partial clone (--filter=blob:none) failed for https://dev.azure.com/<org>/tools; retrying with full bare clone. Server may not support filter v2. [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/packages/csharp #default @d479f42e |-- (files unchanged) [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/instructions/code-style.instructions.md #main |-- 1 instruction(s) integrated -> .github/instructions/ [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/instructions/protect-prefixed-agent-files.instructions.md #main |-- 1 instruction(s) integrated -> .github/instructions/ Partial clone (--filter=blob:none) failed for https://dev.azure.com/<org>/tools; retrying with full bare clone. Server may not support filter v2. [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/skills/git-conventions #default @d479f42e |-- (files unchanged) Partial clone (--filter=blob:none) failed for https://dev.azure.com/<org>/tools; retrying with full bare clone. Server may not support filter v2. [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/skills/update-nuget-packages #default @d479f42e |-- (files unchanged) Partial clone (--filter=blob:none) failed for https://dev.azure.com/<org>/tools; retrying with full bare clone. Server may not support filter v2. [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/skills/write-tests #default @d479f42e |-- (files unchanged) cache-pin: remote dep '<org>/tools/github-copilot-agent-skills' has no resolved_commit; drift cannot verify its cache freshness. Re-run 'apm install' with a pinned ref (commit, tag, or specific branch HEAD). cache-pin: remote dep '<org>/tools/github-copilot-agent-skills' has no resolved_commit; drift cannot verify its cache freshness. Re-run 'apm install' with a pinned ref (commit, tag, or specific branch HEAD). cache-pin: remote dep '<org>/tools/github-copilot-agent-skills' has no resolved_commit; drift cannot verify its cache freshness. Re-run 'apm install' with a pinned ref (commit, tag, or specific branch HEAD). [i] Trusting direct dependency MCP 'MyOrg.CLI' from '<project>-skills' [i] Trusting direct dependency MCP 'NuGet' from '<project>-skills' [i] Trusting direct dependency MCP 'Github' from '<project>-skills' [i] Trusting direct dependency MCP 'MyOrg.CLI' from 'skills' [i] Trusting direct dependency MCP 'NuGet' from 'skills' +- MCP Servers (3) | [+] MyOrg.CLI (already configured) | [+] NuGet (already configured) | [+] Github (already configured) [*] All servers up to date [!] 11 dependencies unpinned: <org>/tools/github-copilot-agent-skills -- add #tag or #sha to prevent drift [!] Transitive package 'csharp-skills' declares self-defined MCP server 'NuGet' (registry: false). Re-declare it in your apm.yml or use --trust-transitive-mcp. [!] Transitive package 'csharp-skills' declares self-defined MCP server 'Github' (registry: false). Re-declare it in your apm.yml or use --trust-transitive-mcp. [*] Installed 11 APM dependencies in 87.9s. > apm install [>] Installing dependencies from apm.yml... [i] Targets: copilot (source: apm.yml) [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/packages/<project> @d479f42e (cached) |-- (files unchanged) [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/packages/myorg @d479f42e (cached) |-- (files unchanged) [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/instructions/testing.instructions.md #main Content hash mismatch for <org>/tools/github-copilot-agent-skills/.apm/instructions/testing.instructions.md: expected sha256:2227579674ab30b5b59f703ac152fa74ac2912d724d04aeffbf3914cac2e6b88, got sha256:b82d09e4e7879eeb0e90cc7dfeebdac45de6ebdbcdda7824b40438196692f8f8. The downloaded content differs from the lockfile record. This may indicate a supply-chain attack. Use 'apm install --update' to accept new content and update the lockfile. [!] Install interrupted after 7.7s.Additional context apm.yml
name: <project>-skills version: 1.0.0 description: '<Project> skills and agent for GitHub Copilot.' author: Oskar Klintrot target: vscode dependencies: apm: - dev.azure.com/<org>/tools/github-copilot-agent-skills/packages/csharp - dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/skills/run-coverage - dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/instructions/testing.instructions.md mcp: - name: NuGet registry: false transport: stdio command: dnx args: - NuGet.Mcp.Server - --source - https://api.nuget.org/v3/index.json - --yesInterface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /apm, current file: none) bash-$
Assistant
Good, matches usage in integrate.py. Now let's verify the edit compiles and run related tests.
Assistant
Now let's write a reproduction script to simulate the second-install scenario at a unit level, verifying the fix behaves correctly, and also check existing tests still pass.
Assistant
Need to install package properly. Let's check environment setup.
Assistant
All existing tests pass. Now let's write a quick reproduction test for the new behavior (no-provenance dep should get a warning instead of sys.exit).
Assistant
The fix works as intended: previously this scenario would have triggered
sys.exit(1), now it warns and proceeds. Let's also confirm the original mismatch scenario (with provenance) still hard-fails.Assistant
All pass. Let's run broader test suite to be safe (at least unit tests, and any integration tests related to content hash/branch drift).
Assistant
Missing dependency unrelated to our change. Let's install it and rerun.
Assistant
All unit tests pass (15812 passed). Let's also run integration tests related to content hash / drift.
Assistant
Let's also run the broader integration test directory quickly to make sure nothing else broke.
Assistant
Confirmed: these 3 failures are pre-existing and unrelated to my change (environment-specific, e.g. running as root bypasses permission checks). Good — our fix doesn't introduce regressions. Let's clean up temp files.
Assistant
These are unrelated side effects (likely from running tests that touched the real repo). Let's revert them since they're not part of our fix.
Assistant
This looks clean. Now let's go through the checklist explicitly.
Assistant
Good — confirmed at line 580, within
FreshDependencySource.acquire()(the class starting around line 550s+). Let's double check whichacquireline 580 belongs to.Assistant
Confirmed: line 580's
logger = ctx.loggerbelongs toFreshDependencySource.acquire(starts at 565). Our patch'sloggerreference at line ~805 is correctly in scope.Now let's do a final review of the full diff and run the complete unit test suite once more for confidence.
Assistant
All 15812 unit tests pass. Let's finalize the checklist review.
Checklist review:
-
[x] If an error was reported in the issue description, I have successfully reproduced it. I traced the exact code path causing "Content hash mismatch" for virtual single-file dependencies on Azure DevOps:
resolve_commit_sha_for_refingit_reference_resolver.pyunconditionally returnsNonefor ADO/Artifactory deps, so virtual single-file packages (e.g..apm/instructions/testing.instructions.md) never get aresolved_commitrecorded in the lockfile. Combined with the fact that these deps are never cache-eligible (always re-downloaded from a floating branch ref), the supply-chain hash check inFreshDependencySource.acquire()had no way to distinguish legitimate branch drift from tampering and hard-failed on every subsequentapm install. I wrote a reproduction script (/tmp/repro_test.py, using the existing test harness intest_sources_materialisation.py) that simulated this exact scenario (noresolved_commiton either side, differing content hash) and confirmed it triggeredsys.exit(1)before my fix. -
[x] If an error was reported in the issue description, I have confirmed that my fix resolves the error. After patching
src/apm_cli/install/sources.py, re-running the same reproduction script shows the install now completes successfully (returns aMaterialization) and emits a warning viadiagnostics.warn/logger.progressinstead of aborting — matching the existing precedent set bycache_pin.py's own "cannot verify cache freshness" warning for this exact class of unpinned/unresolvable dependency. -
[x] I have thought about edge cases and made sure my fix handles them as well. The fix only bypasses the hard failure when both the lockfile-recorded
resolved_commitand the freshly-resolvedresolved_commitare absent/"cached"sentinel — i.e., genuinely no commit-level provenance exists on either side. Whenever a real pinned/resolvable commit SHA is available (tags, commits, GitHub-resolvable branches, ADO directory/subdirectory packages that use git-based resolution), the original hard supply-chain block is preserved unchanged, so real attacks against pinned dependencies are still caught. I verified this by confirming the pre-existingtest_hash_mismatch_calls_sys_exittest (which uses a concreteresolved_commit) still passes unmodified. -
[x] I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. Ran
tests/unit/install/test_sources_materialisation.py(42 tests), the fulltests/unit/installsuite (1477 tests), and the entiretests/unitsuite (15812 passed, 2 skipped, 21 xfailed — all pre-existing skips/xfails). Also rantests/integration, where only 3 pre-existing, environment-specific failures remain (permission-denied tests failing because the sandbox runs as root, and an unrelated ADO bearer-fallback test) — verified viagit stashthat these same 3 failures exist identically on the unmodified codebase, confirming they are unrelated to my change.
-
Assistant
Only the intended source file change remains. Now submitting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →