Skip to content

fix(cli): incorrect cdk diff output for nested stacks#1229

Merged
aws-cdk-automation merged 3 commits intomainfrom
sai/fix-nested-stack-diff-mangled-template
Mar 17, 2026
Merged

fix(cli): incorrect cdk diff output for nested stacks#1229
aws-cdk-automation merged 3 commits intomainfrom
sai/fix-nested-stack-diff-mangled-template

Conversation

@sai-ray
Copy link
Contributor

@sai-ray sai-ray commented Mar 17, 2026

Fixes #1228

cdk diff produces incorrect output for nested stacks when the mangled character filter triggers. The mangled diff computation in formatStackDiffHelper uses this.oldTemplate (root stack's deployed template) instead of the oldTemplate parameter (nested stack's deployed template). This causes the correct nested diff to be overwritten with a meaningless comparison between the root and nested templates.

The fix replaces this.oldTemplate with oldTemplate on one line.

Added unit test for nested stack mangled character filtering.

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

@codecov-commenter
Copy link

codecov-commenter commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.94%. Comparing base (ae037f9) to head (1b62697).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1229   +/-   ##
=======================================
  Coverage   87.94%   87.94%           
=======================================
  Files          74       74           
  Lines       10339    10339           
  Branches     1377     1377           
=======================================
  Hits         9093     9093           
  Misses       1220     1220           
  Partials       26       26           
Flag Coverage Δ
suite.unit 87.94% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

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.

(diff): cdk diff for nested stacks compares against root stack template instead of nested stack template

4 participants