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, so ctx.package_hashes[dep_key] (already set to the fresh hash before the check) will be written into the lockfile regardless of whether we hard-fail or continue. Let's view lines 155-165 in phases/lockfile.py to confirm.

  3. Claude Assistant

    Now let's view the full function to see where resolved_commit is defined relative to the check block, and update the fix.

  4. Claude Assistant

    Now let's update the actual check block:

  5. Claude Assistant

    Now let's verify the change looks correct:

  6. Claude Assistant

    Good — resolved_commit = "abc1234" (truthy, not "cached") and locked_chk.resolved_commit = "sha" (also truthy, not "cached"), so _unpinnable will be False, and the test will still hit the sys.exit(1) path. Let's run this test file to confirm.

  7. Claude Assistant

    All passing. Now let's run the broader install test suite (sources, integrate, resolve) to check for regressions.

  8. Claude Assistant

    All tests pass. Now let's write a quick reproduction test to simulate the exact scenario from the issue (virtual file with no resolved_commit) to confirm the fix resolves it, rather than sys.exit.

  9. Claude Assistant

    The fix works as expected. Now let's clean up the temp script and run the full test suite once more to be safe.

  10. Claude Assistant

    All unit tests pass (15812 passed, 2 skipped, 21 xfailed – no failures). Let's also run the integration tests to be thorough.

  11. Claude Assistant

    All good. Let's also quickly run the full integration suite to be safe (it might take a while but let's try).

  12. Claude Assistant

    Confirmed those 3 failures are pre-existing (running as root breaks chmod-based permission tests) and unrelated to my change. Let's check the other modified files (seems like some git-status artifacts from running the CLI itself during tests, unrelated to our fix). Let's check git diff to make sure only intended file changed, and revert accidental modifications.

  13. Claude Assistant

    Clean now — only the intended fix remains. Let's view the final diff.

  14. Claude Assistant

    This is exactly the change I intended. Let's re-run the relevant test suites one final time to be certain everything is in order.

  15. Claude Assistant

    That failure is the same pre-existing unrelated test (already confirmed failing on the unmodified repo). Everything related to my change passes cleanly.

  16. Claude Assistant

    Now only the intended fix file remains modified.

    Checklist review

    • Reproduced the reported error: Yes — I traced the exact code path (FreshDependencySource.acquire() in src/apm_cli/install/sources.py) that triggers Content hash mismatch ... supply-chain attack ... sys.exit(1), and confirmed via a targeted reproduction script that the unpatched logic would hard-abort for a dependency whose commit could never be pinned (e.g. an Azure DevOps virtual single-file dependency, where resolve_commit_sha_for_ref always returns None for ADO hosts — verified in git_reference_resolver.py). I confirmed the same code path is exercised by the existing test test_hash_mismatch_calls_sys_exit.
  17. Claude Assistant
    • Confirmed the fix resolves it: Yes — I wrote a standalone repro script mimicking the exact scenario (dep with no resolvable commit, both currently and in the lockfile, whose fresh content hash differs from the recorded lockfile hash). Before the fix this scenario aborts install with sys.exit(1); after the fix, it emits a warning via _rich_warning and lets the install continue (the fresh hash is written into ctx.package_hashes, which the lockfile phase already picks up automatically to update the recorded content_hash, so subsequent installs stay quiet). I verified this both by direct inspection of the code path and by running the repro script, which printed PASS.

    • Thought about edge cases:

      • Pinned dependencies (tag or commit SHA) where a real resolved_commit exists on both the current run and the lockfile record are still hard-failed as a genuine supply-chain concern — I kept the original sys.exit(1) + safe_rmtree behavior for that case, guarded by the _unpinnable check requiring both current and previously-locked resolved commits to be missing/"cached".
      • The "cached" sentinel (used elsewhere in the codebase for registry/cache-derived deps where no real SHA is known) is treated the same as None, consistent with existing conventions in integrate.py/sources.py (resolved_commit != "cached" checks).
      • Directory-based git deps that do resolve to a real commit (as in the issue's own log, e.g. packages/csharp @d479f42e) are unaffected — they continue to be verified strictly since resolved_commit is populated.
      • I verified this doesn't disable the check when ctx.update_refs is set or when dep_key is already in ctx.expected_hash_change_deps — those pre-existing bypass paths are untouched; my change only adds a secondary bypass specific to the "impossible to pin" case.
    • Ran existing tests to confirm no regressions: Yes.

      • tests/unit/install/ — 1477 passed (includes test_sources_phase3.py::test_hash_mismatch_calls_sys_exit, which still passes because that test's mocked dependency has a real resolvable commit on both sides).
      • Full tests/unit/ — 15812 passed, 2 skipped, 21 xfailed (no failures).
      • tests/integration/ — 9032 passed, with 3 pre-existing failures unrelated to this change (permission-based tests that fail identically on the unmodified repo because the test suite runs as root, where chmod 0o000 doesn't restrict access) — verified via git stash that these 3 failures exist without my patch too.
      • Cleaned up incidental working-tree mutations produced by the test suite itself (e.g. apm.lock.yaml, various .agents/skills/*) via git checkout --, leaving only the intended source change staged.

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