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
powershell - Assistant
I'll start by exploring the repository structure and locating the content-hash verification logic related to the install failure.
- Assistant
Searching for the content-hash mismatch logic and related install/cache code.
- Assistant
rg is not available, let me use grep.
- Assistant
Inspecting the content-hash verification path and how single-file deps are handled on reinstall.
- Assistant
Looking at integrate-phase hash checks and how hashes are recorded for file vs package deps.
- Assistant
Let me look at compute_package_hash and how lockfile stores content_hash for single files.
- Assistant
Checking how file dependencies are materialized and hashed, and looking at related tests.
- Assistant
Checking how single-file deps are downloaded and looking for relevant changelog/commit history.
- Assistant
Following how individual-file dependencies are downloaded and installed.
- Assistant
So there's "virtual packages" - single file deps. Let me look at VIRTUAL_FILE_EXTENSIONS and how they'll be cached/downloaded. Also read tests about content hash materialisation.
- Assistant
Inspecting install path layout for virtual files and the download/extraction flow.
- Assistant
Let me look closely at download_virtual_file_package
- Assistant
Continue reading
- Assistant
Examining FreshDependencySource download flow and when cached installs are skipped.
- Assistant
Let me continue reading the download part
- Assistant
Checking how skip_download is decided and how virtual packages are downloaded.
- Assistant
The grep with directory might need different syntax.
- Assistant
Let me read integrate.py _resolve_download_strategy fully
- Assistant
Continue reading
- Assistant
Checking alternate download paths and how package hashes are attached for virtual files.
- Assistant
Looking at the unique_key in the error: I understand the issue you're describing. The content hash mismatch for
.apm/instructions/testing.instructions.mdis happening because the file's content differs between the first and secondapm installruns, even though the unique key omits the host prefix.Let me break this down:
- Assistant
Noting virtual-file download doesn't clear the target directory. Checking YAML serialization and
download_raw_filenext. - Assistant
Let me check if there was a recently known issue about this. Look at git log and GH issues related to content hash.
- Assistant
Checking recent content-hash fixes and tests that may document this failure.
- Assistant
Checking what happens after download for package type detection and whether tasks mutate the install path.
- Assistant
Checking what
--forceand--updatemost strongly alter. - Assistant
Checking how commit SHA is resolved for ADO/virtual files.
- Assistant
Let me look at the GitReferenceResolver for ADO
- Assistant
Typo in command
- Assistant
Let me open git_reference_resolver.py around that method.
- Assistant
Inspecting the ADO file download path for non-determinism.
- Assistant
Checking ADO API URL and response handling — it might return JSON instead of raw bytes.
- Assistant
Looking at build_ado_api_url - it uses Items API which returns JSON by default, not raw content! Unless there's Accept header...
- Assistant
Looking through CHANGELOG and issues for related fixes, and drafting a reproduction.
- Assistant
Writing a minimal reproduction of virtual-file download hashing behavior.
- Assistant
Leftover files can cause the hash mismatch. Searching for writes into package install paths after hashing.
- Assistant
When resolved_commit is None/empty, does write_marker still get called with empty commit?
- Assistant
Reviewing the #763 fix and related tests to identify the intended skip-redownload behavior.
- Assistant
Checking the resolve/download phases for the same content-hash skip gap.
- Assistant
Implementing the fix: use content-hash skip when
resolved_commitis missing, and clear the virtual-file target directory before writing. - Assistant
Applying the integrate.py content-hash fallback and related download fixes.
- Assistant
Updating the pre-download skip logic and cleaning the virtual-file target directory.
- Assistant
Cleaning the virtual-file target before write, and writing
apm.ymlwith stable bytes. - Assistant
Need to use exact text from file - maybe whitespace differs. Let me read the exact content.
- Assistant
Let me try smaller replacements.
- Assistant
Now fix write_text
- Assistant
Reproducing the skip logic and leftover-file hash behavior with a temporary script.
- Assistant
Running related unit tests to confirm nothing regressed.
- Assistant
Running more install and virtual-file tests.
- Assistant
Checking heal behavior when content-hash-only match increases:
- Assistant
Running heal and integrate-relatedtests:
- Assistant
Reviewing the final diff:
- Assistant
Verifying download.py structure is correct:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.