Skip to content

fix(toolkit-lib)!: diff message payloads are incomplete #546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 28, 2025

Conversation

mrgrain
Copy link
Contributor

@mrgrain mrgrain commented May 28, 2025

Fixes #494

The messages emitted as part of diff were incomplete when multiple stacks are diffed. Previously the code would overwrite the formatted output with the last processed stack. We are also removing the already deprecated securityOnly option.

To solve this properly, the diff messages have been restructured: For each stack we emit a new message with code CDK_TOOLKIT_I4002 that contains all formatted diffs for the stack (including any nested stacks).

The collated result message CDK_TOOLKIT_I4001 does not contain formatted diffs anymore, but instead has a count for stacks with changes and the structured diff as returned by the action.

BREAKING CHANGE: The data emitted by message CDK_TOOLKIT_I4001 has changed. Instead of formatted diffs, it now contains a stack count and the template diff as returned by the action. The formatted output is now available on a new message CDK_TOOLKIT_I4002. Deprecated option securityOnly removed from DiffOptions used by Toolkit.diff(). Instead the action always prints and returns a security diff. Use a custom IoHost implementation to customize the exact diff output.


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

@aws-cdk-automation aws-cdk-automation requested a review from a team May 28, 2025 12:59
@github-actions github-actions bot added the p2 label May 28, 2025
@mrgrain mrgrain changed the title feat(toolkit-lib): improve diff functionality feat(toolkit-lib)!: improve diff functionality May 28, 2025
@@ -71,7 +71,7 @@ interface FormatStackDiffOptions {
*
* @default 3
*/
readonly context?: number;
readonly contextLines?: number;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This just makes the calling a little nicer.

@codecov-commenter
Copy link

codecov-commenter commented May 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.10%. Comparing base (b04ad30) to head (16b2005).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #546   +/-   ##
=======================================
  Coverage   79.10%   79.10%           
=======================================
  Files          47       47           
  Lines        7074     7074           
  Branches      794      793    -1     
=======================================
  Hits         5596     5596           
  Misses       1457     1457           
  Partials       21       21           
Flag Coverage Δ
suite.unit 79.10% <100.00%> (ø)

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.

Comment on lines +181 to +182
private permissionType(): PermissionChangeType {
const diff = this.diff();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cleanup. permissionType is never called with a stackName. Let's not pretend it should.

@mrgrain mrgrain changed the title feat(toolkit-lib)!: improve diff functionality fix(toolkit-lib)!: diff message payloads are incomplete May 28, 2025
@aws-cdk-automation aws-cdk-automation added this pull request to the merge queue May 28, 2025
Merged via the queue into main with commit 2eb1b84 May 28, 2025
32 of 34 checks passed
@aws-cdk-automation aws-cdk-automation deleted the mrgrain/feat/toolkit-lib/diff-improvements branch May 28, 2025 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@aws-cdk/toolkit-lib: diff command result lacks changed stacks count
4 participants