Repository navigation
Conversation
…esource is already managed by a stack `listResourceScanResources` only threw `NoResourcesFound` when the scan returned nothing. When every matching resource belongs to an existing CloudFormation stack, `excludeManaged` removes all of them after that check, and the empty list reaches `CreateGeneratedTemplate`, which fails with "Value '[]' at 'resources' failed to satisfy constraint". Check the list again after excluding managed resources and explain why nothing is left, pointing at `--from-stack`. Fixes aws#235 Co-Authored-By: Claude Opus 5.5 <[email protected]>
yeegz
requested a deployment
to
integ-approval
November 30, 2026 06:45 — with
GitHub Actions
Waiting
aws-cdk-automation
enabled auto-merge
November 30, 2026 06:45
rix0rrr
approved these changes
Nov 30, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2188 +/- ##
==========================================
- Coverage 92.55% 92.54% -0.02%
==========================================
Files 81 81
Lines 13224 13236 +12
Branches 1917 1918 +1
==========================================
+ Hits 12240 12249 +9
- Misses 946 949 +3
Partials 38 38
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 branch is waiting to be deployed
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 #235
cdk migrate --from-scanwith filters fails withValue '[]' at 'resources' failed to satisfy constraint: Member must have length greater than or equal to 1when every resource that matches the filters already belongs to a CloudFormation stack (for example, the resources of an Amplify stack).In
packages/aws-cdk/lib/commands/migrate.ts,listResourceScanResourcesthrowsNoResourcesFoundonly when the scan returns nothing.excludeManagedruns after that check, so when every match is managed by a stack the list becomes empty.getResourceScanRelatedResourcesgets an empty input and returns an empty list, and that goes toCreateGeneratedTemplate, which rejects it.This change checks the list again after
excludeManagedand throws aToolkitError(NoUnmanagedResourcesFound) that says why nothing is left, as proposed in the issue:Without filters it reads
All N scanned resources are already managed .... TheMIGRATE_INTEG_TESTpath is unchanged.Tests:
test/commands/migrate.test.ts: the scan returns two resources that both haveManagedByStack: true.generateTemplatenow rejects with the message above, andCreateGeneratedTemplateis never called. Before the fix the test fails becausegenerateTemplateresolves after sending an empty resource list.ListResourceScanResourcesmock in thegenerateTemplatetests used to return a resource markedManagedByStack: true. Those tests were going through this same empty-list path, which the mockedCreateGeneratedTemplateaccepted. The mock now returns an unmanaged copy of that resource, so those tests run the normal path. Their expected output does not change.npx jest test/commands/migrate.test.ts: 37 pass. The one failure is the C#generateCdkApptest, which needsdotnetand does not run on my machine (spawn dotnet ENOENT). It is not related to this change. eslint passes on both files.Decision to flag: the message copies the style of the existing
NoResourcesFoundmessage in the same function (capital letter, full stop) and the wording proposed in the issue. The AGENTS.md style asks for lowercase with no full stop, so I can change it if you prefer.I used an AI coding assistant to help write this change. I reviewed and tested it myself.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license