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

Detect and correct "incorrect" use of new FnJoin #516

Merged
merged 3 commits into from
Aug 7, 2018

Conversation

RomainMuller
Copy link
Contributor

@RomainMuller RomainMuller commented Aug 7, 2018

A common developer error is to pass an array as the second argument of
new FnJoin, but that argument is variadic. This causes invalid
CloudFormation templates to be generated. This change corrects the
API to match the Fn::Join syntax where the second argument is an
array.

Related to #512

A common developer error is to pass an array as the second argument of
`new FnJoin`, but that argument is variadic. This causes invalid
CloudFormation templates to be generated. This change detects this usage
pattern (vararg contains a single element that is an array) and fixes
it up transparently.

Related to #512
@RomainMuller RomainMuller requested a review from eladb August 7, 2018 09:13
@@ -88,6 +88,18 @@ export class FnJoin extends Fn {
* @param listOfValues The list of values you want combined.
*/
constructor(delimiter: string, ...listOfValues: any[]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I rather we align the signature here to CloudFormation instead of be "smart" about it. FnConcat is a nice sugar on top that has a variadic signature.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also missing test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Can do that then.


export = nodeunit.testCase({
'Fn::Join': {
'rejects empty list of arguments to join'(test: nodeunit.Test) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure there aren’t already tests for these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasonably:

  1. Nothing showed up in /test/ when I grep'd for FnJoin(.
  2. There was no test.fn.ts and that's where I expect those unit tests to be

@RomainMuller
Copy link
Contributor Author

I'm tracking down places where the "old" syntax was used and fixing those (they are what causes the CodeBuild to fail).

@RomainMuller RomainMuller merged commit 42b108d into master Aug 7, 2018
@RomainMuller RomainMuller deleted the rmuller/512-unexpected-use-of-fn-join branch August 7, 2018 12:04
@NGL321 NGL321 added the contribution/core This is a PR that came from AWS. label Sep 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants