Repository navigation
fix(prune): keep package removal when the local bundle hook re-check cannot resolve targets - #4141
Merged
Daniel Meppiel (danielmeppiel) merged 6 commits intoNov 20, 2026
Conversation
…cannot resolve targets Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 20, 2026 08:27
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Prune can restore stale deployment records after hook revocation and suppress trust or retirement failures, potentially leaving an unapproved hook executable while exiting successfully.
2 open issues
What changed in this PR
This PR addresses a regression introduced by #4061 where a local-bundle hook target-resolution failure stopped apm prune and was reported as an apm.yml parse error.
Changes:
- Moves the hook trust re-check outside manifest parsing.
- Logs non-policy re-check failures as warnings so package removal can continue, while retaining failure behavior for
PolicyViolationError. - Adds an Unreleased changelog entry for the prune fix.
| File | Description |
|---|---|
src/apm_cli/commands/prune.py |
Separates hook re-check error handling from manifest parsing. |
CHANGELOG.md |
Documents continued package removal when hook target resolution fails. |
Review effort: Balanced
… stay fatal Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-4027-prune-recheck
branch
November 20, 2026 10:19
4 of 10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
apm pruneexited 1 with "Failed to parse apm.yml: ..." when target resolution failed during the local-bundle hook re-check, a step #4061 added. The re-check ran inside theapm.ymlparsetry, so its error was reported as a parse failure and package removal stopped.The re-check now runs after the parse:
BundleHookTargetsUnresolved, raised only around target resolution), prune warns that local bundle hooks were NOT re-checked, points toapm install, and continues. The re-check writes nothing before targets resolve, so the zero-write guarantee holds.apm pruneexit 1.The lockfile is read after the re-check, so prune's own lockfile write keeps the rows the re-check retired;
tests/integration/test_trust_integrity_consistency_lifecycle.py::test_one_prune_retires_revoked_bundle_hooks_and_removes_an_orphancovers one prune that does both. No test was relaxed. New unit tests intests/unit/test_prune_command.py::TestPruneLocalBundleHookRecheckcover the warn path and the fail-closed path. Mutation-break: broadening the catch toExceptionfails the fail-closed test.tests/integration/test_hook_wipe_target_scope_e2e.py::test_zero_write_abort_before_destructive_wipe_on_prunekeeps its zero-write and exit-0 assertions.Issue and approved scope
Issue: Refs #4027
Human scope-approval comment: #4027 (comment) (regression repair for item 5, #4061)
Does this PR complete the issue, or what remains? #4027 is already closed (milestone 0.37.0); this repairs a regression in its merged part 2 (#4061). No open issue to close.
Type of change
Testing
The existing e2e test fails on main and passes with this fix. Each command below was run with
APM_E2E_TESTS=1 APM_RUN_INTEGRATION_TESTS=1.pytest tests/integration/test_hook_wipe_target_scope_e2e.py -k zero_writeon main: failed (Failed to parse apm.yml: simulated target resolution failure, exit 1).pytest -n 2 tests/integration/test_hook_wipe_target_scope_e2e.py tests/unit/test_prune_command.py tests/integration/test_trust_integrity_consistency_lifecycle.py::test_revoked_bundle_grant_retires_its_hookswith this fix: 100 passed.ruff checkandruff format --checkonsrc/ tests/, pylint R0801,lint-auth-signals.shandlint-architecture-boundaries.sh: clean.Changelog
## [Unreleased]inCHANGELOG.md.Spec conformance (OpenAPM v0.1)
No
req-XXXbehaviour changes.