aws / aws/aws-cdk

diff: api gateway model property with the name 'constructor' causes the diff to fail

Open
#22,920 1 comment 0 reactions 0 assignees View on GitHub
bug effort/medium p2 package/tools
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

When adding an apigateway model property with the name `constructor`, the `diff` command fails.

However, both `synth` and `deploy` work with no errors.

### Expected Behavior

That the diff is successfully run with no errors

### Current Behavior

The following exception is printed:

```
> cdk diff

Stack CdkDiffErrorReproStack
Resources
[-] AWS::ApiGateway::Deployment apiDeployment149F129455a2c7a6e9d9c0803747ddbb94cacb02 destroy
[+] AWS::ApiGateway::Deployment api/Deployment apiDeployment149F12944d4e224e8b50bc20017e5f7fab3b5dc9
[~] AWS::ApiGateway::Stage api/DeploymentStage.prod apiDeploymentStageprod896C8101
└─ [~] DeploymentId
└─ [~] .Ref:
├─ [-] apiDeployment149F129455a2c7a6e9d9c0803747ddbb94cacb02
└─ [+] apiDeployment149F12944d4e224e8b50bc20017e5f7fab3b5dc9
[~] AWS::ApiGateway::Model api/model apimodel112FD24C
└─ [~] Schema
└─ [~] .properties:
└─ [~] .constructor:

Cannot read properties of undefined (reading 'split')
```

### Reproduction Steps

1. Clone this repo: https://github.com/clementallen/cdk-diff-error-repro
2. Deploy to an AWS account
3. Uncomment the `constructor` model property here: https://github.com/clementallen/cdk-diff-error-repro/blob/master/lib/cdk-diff-error-repro-stack.ts#L22
4. Run `cdk diff`
5. Observe the exception

### Possible Solution

It would seem this is because `constructor` is a reserved word in TS/JS. However, I've tested a range of other reserved words (`const`, `true`, `export`) and they don't show the same error

### Additional Information/Context

_No response_

### CDK CLI Version

2.50.0 (build 4c11af6)

### Framework Version

_No response_

### Node.js Version

v16.17.0

### OS

MacOS 12.6.1

### Language

Typescript

### Language Version

Typescript (4.8.4)

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with lib/cdk-diff-error-repro-stack.ts at the linked line, uncomment the constructor model property, and run cdk diff after deploying the reproduction. Done means cdk diff completes successfully without the Cannot read properties of undefined error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
api, cli, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.