[BUG] apm --version reports unrelated parent Git repository SHA
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.8k
- Forks
- 362
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 132
Description
Describe the bug
apm --version can report an unrelated parent Git repository commit as though it were the APM build commit.
The packaged apm_cli.version.get_build_sha() has no injected __BUILD_SHA__. For a non-frozen installation it runs git rev-parse --short HEAD from its installed Python library directory. Git walks upward and may discover an unrelated ancestor repository.
To Reproduce
With APM 0.31.0 installed through Homebrew, run:
$ apm --version
Agent Package Manager (APM) CLI version 0.31.0 (edb70f031e)
The displayed SHA belongs to the Homebrew repository rather than APM:
$ git -C /opt/homebrew show -s --format='%H%n%s' edb70f031e
edb70f031e4170c780799633a1226ff73e1077f4
Merge pull request #24018 from Homebrew/sandbox-security-review
For comparison, the native APM v0.31.0 release archive reports:
Agent Package Manager (APM) CLI version 0.31.0 (8fd10ac)
Expected behavior
Installed PyPI/Homebrew packages should either:
- report a release SHA embedded during the package build, or
- omit the SHA when no trustworthy APM source checkout can be identified.
Runtime Git fallback should only be used after proving that the resolved repository is the APM source checkout. It must not accept an arbitrary ancestor Git repository.
Environment (please complete the following information):
- OS: macOS
- Python Version: 3.14.7
- APM Version: 0.31.0 installed with the Homebrew core formula
- VSCode Version (if relevant): Not applicable
Logs
The relevant command output is included in the reproduction above.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting apm_cli.version.get_build_sha() and the package build path that supplies BUILD_SHA. Reproduce apm --version from an installed package inside an unrelated Git checkout, then verify that the command reports an embedded release SHA or omits the SHA rather than accepting an ancestor repository. Confirm behavior for a genuine APM source checkout as well.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100