fix(cli): refactor fails on stacks with bundled assets, even for pure construct moves - #1812
Open
go-to-k wants to merge 1 commit into
Open
fix(cli): refactor fails on stacks with bundled assets, even for pure construct moves#1812go-to-k wants to merge 1 commit into
go-to-k wants to merge 1 commit into
Conversation
…is skips bundling
aws-cdk-automation
enabled auto-merge
August 11, 2026 05:56
go-to-k
requested a deployment
to
integ-approval
August 11, 2026 05:56 — with
GitHub Actions
Waiting
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1812 +/- ##
=======================================
Coverage 90.32% 90.32%
=======================================
Files 80 80
Lines 12124 12125 +1
Branches 1716 1716
=======================================
+ Hits 10951 10952 +1
Misses 1139 1139
Partials 34 34
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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 #1810
Problem
BUNDLING_COMMANDSinpackages/aws-cdk/lib/cli/user-configuration.tsis the explicit list of CLI commands that perform asset bundling during synthesis.refactoris not in it, so the synthesis performed bycdk refactorskips bundling for all stacks. For bundled assets likeNodejsFunction, the asset hash (and therefore theS3Keyin the synthesized template) is then computed from the source directory instead of the bundled output, so it differs from the deployed template. The refactor operation sees this as a property modification and CloudFormation rejects it:This happens even for a pure construct-tree move with no code changes.
importwas deliberately added to this list for the same reason (it also compares the synthesized template against the deployed one);refactorwas added later and never included.Fix
Add
Command.REFACTORtoBUNDLING_COMMANDS, so that the synthesis performed bycdk refactorbundles assets the same waycdk deploydoes, and the synthesized template matches the deployed one when nothing but the construct tree changed.Testing
test/cli/configuration.test.ts:bundlingStacksdefaults to['**']for therefactorcommand (same pattern as the existingdeploy/watchtests).NodejsFunctionmoved into a new construct scope (no code changes):By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license