aws-cloudformation / aws-cloudformation/cloudformation-cli-typescript-plugin

Resource model break when specifying an array with unique: true

Open
#97 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
46
Forks
18
PR merge metrics
No merged PRs in 30d

Description

I've noticed when specifying an array with unique: true translates the model into a Set instead of an Array (makes sense)

but then when passing an actual array as example input, the resource provider fails. Consider for example:

```
"Tags": {
"type": "array",
"maxItems": 50,
"uniqueItems": true,
"insertionOrder": false,
"description": "An array of key-value pairs to apply to this resource.",
"items": {
"$ref": "#/definitions/Tag"
}
},
```

with input:

```
"Tags": [{
"Key": "name",
"Value": "value"
}]
```

gives error

`"message": "Error: Error: Unsupported type: object [Tag] for tags (Error)",`

Removing the `uniqueItems` fixes the issue and the main thing I notice is that in the generated code the type changes from a Set to an Array

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with the shown schema and example input, then inspect the generated TypeScript model and resource-provider path for arrays with uniqueItems enabled. Compare the behavior with uniqueItems removed; done means the example array of Tag objects is accepted while uniqueness remains represented correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
backend-api-design, 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.