Repository navigation
fix(policy): dry-run previews an org policy block when policy cannot be resolved - #4466
Merged
Daniel Meppiel (danielmeppiel) merged 2 commits intoNov 21, 2026
Merged
Conversation
…be resolved (#4455) Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 20, 2026 18:36
Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Blocking previews raise AttributeError because the logger adapters lack warning(), breaking default trust-policy resolution with raise_blocking_errors=False and the lifecycle preview tests.
1 open issue
What changed in this PR
This PR addresses #4455 by adding blocked-policy previews to the shared policy-outcome router, so dry runs explain when an unresolved org policy would block installation without changing exit status or writing state.
Changes:
- Emit a warning when a dry run suppresses a blocking policy error.
- Add a unit regression and enable the existing lifecycle check.
- Update generated coverage obligations, the bug ledger, and changelog.
| File | Description |
|---|---|
tests/unit/policy/test_pr_832_findings.py |
Adds an assertion for the blocked-policy preview warning. |
tests/quality/generated_obligations.json |
Refreshes required lifecycle coverage mappings. |
tests/lifecycle/security/test_policy_outcomes.py |
Removes the expected-failure marker from the dry-run block check. |
tests/fixtures/lifecycle_bug_ledger.json |
Records #4455 and its regression coverage. |
src/apm_cli/policy/outcome_routing.py |
Emits a warning for suppressed blocking outcomes. |
CHANGELOG.md |
Documents the dry-run preview fix. |
Review effort: Balanced
| ) | ||
| if route.blocks and logger is not None: | ||
| # A dry run previews the block the real command applies (#4455). | ||
| logger.warning(f"Would be blocked by policy: {route.block_reason}") |
5 of 10 tasks
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-s20-dry-run-policy-block
branch
November 21, 2026 05:24
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
With
policy.fetch_failure_default: blockand no enforceable org policy,apm installrefuses, butapm install --dry-runprinted nothing about it. The policy-outcome routing owner (policy/outcome_routing.route_discovery_outcome) now emitsWould be blocked by policy: <reason>when a dry run suppresses the blocking error. Every dry-run caller (install preflight, local bundle) goes through it. The exit code is unchanged (0) and nothing is written.Issue and approved scope
Issue: Fixes #4455
Human scope-approval comment: see #4455.
Does this PR complete the issue, or what remains? It completes it.
Type of change
Testing
Tested locally
All existing tests pass
Added tests for new functionality (if applicable)
tests/unit/policy/test_pr_832_findings.py::TestOutcomeRoutingTable::test_dry_run_previews_the_fetch_failure_default_block: fails before the change (no warning emitted) and passes after.The strict lifecycle cell
test_policy_outcomes.py::test_site_routes_the_outcome[install-dry-run-preflight|cache_miss_fetch_fail/block]is now required (witnesses regenerated: 925 required).tests/unit/policy/: 1407 passed. Ledger tests pass; ruff and architecture boundaries are clean.Changelog
## [Unreleased]inCHANGELOG.md.Spec conformance (OpenAPM v0.1)