Skip to content

fix(deploy): show CloudFormation resource failure after rollback - #2760

Merged
nborges-aws merged 2 commits into
v1.xfrom
fix/deploy-02
Nov 5, 2026
Merged

nborges-aws merged 2 commits into
v1.xfrom
fix/deploy-02

Conversation

@nborges-aws

Copy link
Copy Markdown
Contributor

Description

Capture the failed resource event emiitted by CDK toolkit and include it in the reason field when deploy fails. This makes the cause visible when Toolkit returns a NoStack error after a rollback. The original error remains visible as well.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

Testing

How have you tested the change?

  • I ran bun test
  • I ran the relevant end-to-end tests with bun run test:e2e, or explained why they are not applicable
    (CI does not run them for you)
  • I ran bun run typecheck
  • I ran bun run lint:check
  • I ran bun run format:check
  • I ran bun run audit
  • I ran bun run secrets:check
  • I ran bun run build
  • If I modified src/assets/, I updated affected snapshots with bun test <test-file> --update-snapshots and committed them
  • If I re-recorded fixtures or golden files, every change beyond account identifiers is explained
    by this PR
  • This PR does not change command.md (the release workflow regenerates it)

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.

@nborges-aws
nborges-aws requested a review from a team November 4, 2026 18:25
@github-actions github-actions Bot added the size/s PR size: S label Nov 4, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added agentcore-harness-reviewing AgentCore Harness review in progress claude-security-reviewing Claude Code /security-review in progress and removed agentcore-harness-reviewing AgentCore Harness review in progress labels Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Package Tarball

aws-agentcore-1.0.1.tgz

How to install

gh release download pr-2760-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-1.0.1.tgz

@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Nov 4, 2026
operation.kind === "deploy" &&
error instanceof Error &&
firstFailure &&
!error.message.includes(firstFailure.reason)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dedupe misses on the update path. When the stack already exists, Toolkit's own diagnosis works and already includes the reason. But it wraps each reason at 120 chars (formatResourceErrorBlock in diagnosing/diagnosis-formatting.js:128, wrapText(120, e.message)). AgentCore reasons are almost always longer than that, so includes(reason) is false and users see the cause twice.

The only case where the cause is lost is NoStack. ToolkitError sets name to the error code (toolkit-error.js:85), so gating on that is tighter:

if (error instanceof Error && error.name === "NoStack" && firstFailure) {

That also stops the failure from being attached to unrelated errors thrown later in performCdkOperation (e.g. the "deployed no stack" error at L251). The test would need to throw an error with name = "NoStack" instead of a plain Error.

return await performCdkOperation(loaded, operation, options);
} catch (error) {
if (
operation.kind === "deploy" &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bootstrap goes through the same monitorDeployment path, so a first bootstrap that rolls back can hit the same NoStack. Is excluding it intentional? If you gate on NoStack (comment below), this kind check can go.

...(message.code && { code: message.code }),
})
.debug(message.message);
if (message.code === "CDK_TOOLKIT_I5502" && onResourceFailure) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a why-comment here? Two things aren't obvious from the code:

  1. I5502 is Toolkit's per-event stack activity message.
  2. This whole path is a stopgap. In toolkit-lib 1.38.2, deploy-stack.js:411 reads finalState.wrapped before diagnoseFromErrorCollection, so a first create that rolls back throws NoStack and drops Toolkit's own resource diagnosis. The cancelled filter mirrors Toolkit's isCancellationEvent.

@github-actions github-actions Bot added size/m PR size: M and removed size/s PR size: S labels Nov 5, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Nov 5, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Nov 5, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.55%. Comparing base (272585d) to head (bddb182).

Additional details and impacted files
@@           Coverage Diff           @@
##             v1.x    #2760   +/-   ##
=======================================
  Coverage   96.54%   96.55%           
=======================================
  Files         706      706           
  Lines       58626    58657   +31     
=======================================
+ Hits        56603    56635   +32     
+ Misses       2023     2022    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nborges-aws
nborges-aws merged commit 49fa285 into v1.x Nov 5, 2026
21 of 22 checks passed
@nborges-aws
nborges-aws deleted the fix/deploy-02 branch November 5, 2026 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants