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

(cdk migrate): wrong migration of "special character" JSON Keys ("application/json" -> applicationJson) #29216

Closed
jwoehrle opened this issue Feb 22, 2024 · 3 comments
Assignees
Labels
bug This issue is a bug. p1 package/tools Related to AWS CDK Tools or CLI toolkit/migrate Related to cdk migrate

Comments

@jwoehrle
Copy link
Contributor

Describe the bug

I'm using CDK migrate to create a CDK app for my already deployed CloudFormation Stack.

The CFN template contains an AWS::ApiGateway::Method with the following property:

"RequestModels": {
          "application/json": {
            "Ref": "ApiGatewayMethodHelloPostApplicationJsonModel"
          }
        }

note the / in the JSON key of application/json

This gets migrated into the following L1 construct code:

requestModels: {
        applicationJson: apiGatewayMethodHelloPostApplicationJsonModel.ref,
      },

which after synth gives us:

      RequestModels:
        applicationJson:
          Ref: ApiGatewayMethodHelloPostApplicationJsonModel

which fails the cdk deploy with the following message

failed: Error: The stack named serverless-project-dev failed to deploy: UPDATE_ROLLBACK_FAILED (The following resource(s) failed to update: [ApiGatewayMethodHelloPost]. ): Resource handler returned message: "Validation Result: warnings : [], errors : [Invalid content type specified: applicationJson] (Service: ApiGateway, Status Code: 400, Request ID: 26885dad-a6cb-45a2-8640-53bddad60568)" (RequestToken: d7151781-c4b7-8fae-7545-49b6c1c2eaa2, HandlerErrorCode: InvalidRequest), Resource handler returned message: "Invalid Method identifier specified (Service: ApiGateway, Status Code: 404, Request ID: f25f0c89-6591-41fc-bf0b-33382df1b91f)" (RequestToken: 1ec85c11-87f6-7ced-b3a5-a1018561425f, HandlerErrorCode: NotFound)
...

when I change applicationJson to "application/json" (enclosed in ") the deployment succeeds

Expected Behavior

deployment succeeds and JSON properties are not changed between original CFN stack and resulting/migrated CDK/CFN stack

Current Behavior

quoted String "application/json" gets changed to applicationJson (not quoted)

Reproduction Steps

see above CFN snippet

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.128.0 (build d995261)

Framework Version

No response

Node.js Version

v20.9.0

OS

macOS

Language

TypeScript

Language Version

~5.3.3

Other information

No response

@jwoehrle jwoehrle added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 22, 2024
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Feb 22, 2024
@tim-finnigan tim-finnigan added the toolkit/migrate Related to cdk migrate label Feb 22, 2024
@tim-finnigan tim-finnigan self-assigned this Feb 22, 2024
@tim-finnigan tim-finnigan added p1 investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Feb 22, 2024
@TheRealAmazonKendra
Copy link
Contributor

The fix for this was released in v2.132.

Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p1 package/tools Related to AWS CDK Tools or CLI toolkit/migrate Related to cdk migrate
Projects
None yet
Development

No branches or pull requests

3 participants