Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-5· anthropicHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION [BUG] apm install fail second time with Content hash mismatch Describe…

  1. 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 run apm install it will fail consistently with Content hash mismatch.

    To Reproduce Steps to reproduce the behavior:

    1. apm install <repo>
    2. 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
        - --yes
    

    Interface

    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 using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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-$

  2. Claude Assistant

    Good, matches usage in integrate.py. Now let's verify the edit compiles and run related tests.

  3. Claude 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.

  4. Claude Assistant

    Need to install package properly. Let's check environment setup.

  5. Claude 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).

  6. Claude 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.

  7. Claude 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).

  8. Claude Assistant

    Missing dependency unrelated to our change. Let's install it and rerun.

  9. Claude Assistant

    All unit tests pass (15812 passed). Let's also run integration tests related to content hash / drift.

  10. Claude Assistant

    Let's also run the broader integration test directory quickly to make sure nothing else broke.

  11. Claude 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.

  12. Claude 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.

  13. Claude Assistant

    This looks clean. Now let's go through the checklist explicitly.

  14. Claude Assistant

    Good — confirmed at line 580, within FreshDependencySource.acquire() (the class starting around line 550s+). Let's double check which acquire line 580 belongs to.

  15. Claude Assistant

    Confirmed: line 580's logger = ctx.logger belongs to FreshDependencySource.acquire (starts at 565). Our patch's logger reference 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.

  16. Claude 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_ref in git_reference_resolver.py unconditionally returns None for ADO/Artifactory deps, so virtual single-file packages (e.g. .apm/instructions/testing.instructions.md) never get a resolved_commit recorded 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 in FreshDependencySource.acquire() had no way to distinguish legitimate branch drift from tampering and hard-failed on every subsequent apm install. I wrote a reproduction script (/tmp/repro_test.py, using the existing test harness in test_sources_materialisation.py) that simulated this exact scenario (no resolved_commit on either side, differing content hash) and confirmed it triggered sys.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 a Materialization) and emits a warning via diagnostics.warn/logger.progress instead of aborting — matching the existing precedent set by cache_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_commit and the freshly-resolved resolved_commit are 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-existing test_hash_mismatch_calls_sys_exit test (which uses a concrete resolved_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 full tests/unit/install suite (1477 tests), and the entire tests/unit suite (15812 passed, 2 skipped, 21 xfailed — all pre-existing skips/xfails). Also ran tests/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 via git stash that these same 3 failures exist identically on the unmodified codebase, confirming they are unrelated to my change.

  17. Claude Assistant

    Only the intended source file change remains. Now submitting.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.