Skip to content

fix(toolkit-lib): warn when hook failure detail can't be fetched - #1950

Merged
aws-cdk-automation merged 2 commits into
mainfrom
mrgrain/fix/toolkit-lib/warn-on-hook-detail-fetch-failure
Sep 7, 2026
Merged

fix(toolkit-lib): warn when hook failure detail can't be fetched#1950
aws-cdk-automation merged 2 commits into
mainfrom
mrgrain/fix/toolkit-lib/warn-on-hook-detail-fetch-failure

Conversation

@mrgrain

@mrgrain mrgrain commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #1923

If your deploy role doesn't have cloudformation:ListHookResults / cloudformation:GetHookResult (common for custom CDK Pipelines deploy roles or hand-rolled least-privilege roles), a failed CloudFormation Hook used to give you no indication that more detail existed — the lookup failed silently and only showed up in --debug logs. You'd see the exact same generic message whether the hook truly had nothing more to say, or the CLI just couldn't ask.

Before

❌  Deployment failed: Error: The stack named MyStack failed creation, it may need to be manually deleted.

Change set creation failed. The following hook(s) failed: [Example::CFNHook::Full]

(No hint that more detail exists. The real reason is buried in --debug output.)

After

❌  Deployment failed: Error: The stack named MyStack failed creation, it may need to be manually deleted.

Change set creation failed. The following hook(s) failed: [Example::CFNHook::Full]

   Could not fetch extra hook failure detail for change set cdk-deploy-change-set (User: arn:aws:sts::123456789012:assumed-role/cdk-pipeline-deploy-role/example-runner is not authorized to perform: cloudformation:ListHookResults ...). Run again with -v to see the full error.

The warning is attached to the reported error itself and rendered right after the failure message, so you know it's worth investigating instead of assuming the hook had nothing more to say. The full underlying error is available with -v.

This applies both to ListHookResults (used by cdk deploy and cdk diagnose to find hooks that failed a change set) and GetHookResult (used to fetch a hook's detailed failure reason, e.g. Guard Hook annotations).

What was tested

Updated and added unit tests in stack-diagnoser.test.ts and stack-activity-monitor.test.ts covering the warning being attached on fetch failure. Full toolkit-lib test suite (134 suites, 2031 tests) and lint pass.

Checklist

  • This change contains a major version upgrade for a dependency and I confirm all breaking changes are addressed
    • Release notes for the new version:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Previously, if ListHookResults or GetHookResult failed (e.g. due to a
custom deploy role missing cloudformation:ListHookResults), the
failure was only logged at debug level and silently swallowed,
leaving users with a generic error and no indication that more
detail might exist.

Both paths now always warn at normal verbosity with a short, friendly
message pointing users to `-v` for the full underlying error, instead
of special-casing specific error types or IAM actions.

Fixes #1923
@mrgrain
mrgrain deployed to automation September 7, 2026 12:19 — with GitHub Actions Active
@mrgrain
mrgrain deployed to automation September 7, 2026 12:19 — with GitHub Actions Active
@aws-cdk-automation
aws-cdk-automation requested a review from a team September 7, 2026 12:19
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions github-actions Bot added the p2 label Sep 7, 2026
@mrgrain
mrgrain deployed to no-approval September 7, 2026 12:19 — with GitHub Actions Active
@aws-cdk-automation
aws-cdk-automation added this pull request to the merge queue Sep 7, 2026
Merged via the queue into main with commit 03aebdc Sep 7, 2026
46 checks passed
@aws-cdk-automation
aws-cdk-automation deleted the mrgrain/fix/toolkit-lib/warn-on-hook-detail-fetch-failure branch September 7, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

toolkit-lib: hook failure detail lookup silently swallowed by AccessDenied on custom deploy roles (follow-up to #1768)

4 participants