fix(toolkit-lib): hooks without annotations fail deployments without showing failure details - #1768
Merged
aws-cdk-automation merged 1 commit intoJul 28, 2026
Conversation
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
iankhou
approved these changes
Jul 28, 2026
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.
Fixes #
CloudFormation Hooks that don't emit annotations — notably
AWS::Hooks::LambdaHookand other custom hooks — failed deployments without ever showing the user why. The detailed failure reason lives in theHookStatusReasonof theGetHookResultresponse, but the CLI only extracted failed Guard Hook annotations from that response and discarded everything else, so users were left with the generic "see hook results for details" message from the stack event. Hooks that fail change set creation (TargetType: CHANGE_SET) were worse off still: that code path never consulted the hook result APIs at all and reported only the change set's status reason.The annotation formatting is extracted into a shared helper that falls back to the hook result's own
HookStatusReasonwhen there are no failed annotations, because for non-Guard hooks that field is the only place the details exist. The stack activity monitor uses this helper when enriching failed hook events. The change set diagnoser gains a step that runs afterDescribeEventsyields nothing: it lists failed hooks viaListHookResults, fetches each result for annotations, and reports the details as diagnosis problems before falling back to the generic change set error. Only hooks with failure modeFAILare considered, sinceWARNhooks cannot have caused the change set failure. Both lookups degrade gracefully to the previous behavior when the APIs are unavailable, so no new permissions are required; the deploy role'sAWSCloudFormationReadOnlyAccesspolicy already coversListHookResults.Before/After
A Lambda Hook targeting change set operations fails the deployment. Before, the user only sees which hook failed, not why (illustrative output):
After, the detailed reason returned by the hook is fetched from the hook result APIs and included:
The same applies to hooks failing during stack deployment (
RESOURCE/STACKtargets). Before, the event line carried only the generic reason:After, the event is enriched with the hook result's status reason, the same way Guard Hook annotations already were:
Testing
Verified with unit tests for both code paths (a repro test using the reported hook result payload failed before the fix and passes after; the full toolkit-lib suite passes), and a new integration test that deploys a real Lambda Hook targeting change set operations and asserts the detailed reason appears in the
cdk deployoutput. The integration test has not been run against AWS yet and will be exercised by the PR build.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license