Skip to content
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

(cli): migrate fails when retrieving records #235

Open
1 task
mbonig opened this issue Mar 14, 2025 · 3 comments
Open
1 task

(cli): migrate fails when retrieving records #235

mbonig opened this issue Mar 14, 2025 · 3 comments

Comments

@mbonig
Copy link

mbonig commented Mar 14, 2025

Describe the bug

While running:

cdk migrate -n <an existing amplify stack> --filter 'tag-key=user:Application,tag-value=some-value'

I get an error:

1 validation error detected: Value '[]' at 'resources' failed to satisfy constraint: Member must have length greater than or equal to 1

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

I would have expected no errors and for the CLI to generate a CDK project based on the given stack

Current Behavior

Fails with an error

Reproduction Steps

  • run an IaC Generator scan against an account.
  • cdk migrate -n --filter 'tag-key=user:Application,tag-value=some-value'

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.1004.0 (build f0ad96e)

Framework Version

No response

Node.js Version

20.11

OS

macos 15.3.1

Language

TypeScript

Language Version

No response

Other information

No response

@pahud
Copy link

pahud commented Mar 17, 2025

Hi @mbonig,

Thank you for reporting this issue. After investigating the code, I've identified the root cause of the error you're seeing:

Root Cause Analysis

The error "Value '[]' at 'resources' failed to satisfy constraint: Member must have length greater than or equal to 1" occurs because:

  1. The tag filter query returns no matching resources
  2. This leads to an empty resource list being passed to the CloudFormation createGeneratedTemplate API
  3. The API rejects this request because it requires at least one resource to generate a template

The issue likely stems from one of these scenarios:

  • No resources exist with the exact tag key-value pair specified
  • Tag case mismatch (tags are case-sensitive)
  • The resources exist but are not visible to the scan

I would have expected no errors and for the CLI to generate a CDK project based on the given stack

I think CDK CLI should have more verbose error messages.

Bringing this up to the team for further inputs.

@pahud pahud added p2 and removed investigating labels Mar 17, 2025
@iliapolo
Copy link
Contributor

@mbonig

I would have expected no errors and for the CLI to generate a CDK project based on the given stack

Which stack are you referring to? the command creates a new stack based on the resources that match the filter, since no resource match the filter, no stack can be created.

cdk migrate -n

You mention "an existing amplify stack", but the -n option is expected to be given the name of the newly created stack, can you clarify what your expectation here was?

Agree with @pahud that we should provide a better error in this case, but the behavior itself seems expected.

@mbonig
Copy link
Author

mbonig commented Mar 24, 2025

@mbonig

I would have expected no errors and for the CLI to generate a CDK project based on the given stack

Which stack are you referring to? the command creates a new stack based on the resources that match the filter, since no resource match the filter, no stack can be created.

True, I ran the command incorrectly.

cdk migrate -n

You mention "an existing amplify stack", but the -n option is expected to be given the name of the newly created stack, can you clarify what your expectation here was?

Agreed, there shouldn't have been anything in the results.

Agree with @pahud that we should provide a better error in this case, but the behavior itself seems expected.

Sounds good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants