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

fix(core): nested Fn.join with token fails #5679

Merged
merged 1 commit into from
Jan 7, 2020

Conversation

eladb
Copy link
Contributor

@eladb eladb commented Jan 7, 2020

Fn.join has an optimization to flatten nested joins with the same delimiter:

Fn.join(",", [ Fn.join(",", [ "a", "b" ]), "c" ]) == Fn.join(",", [ "a", "b", "c" ])

The logic in isSplicableFnJoinIntrinsic checks if the object is an Fn::Join which uses the same delimiter, and then splices (...) the inner value onto the outer Fn::Join instead of nesting the inner Fn::Join. This can only work if the inner value is a real array (otherwise, we get Found non-callable @@iterator).

The fix is to add an additional check to isSplicableFnJoinIntrinsic which verifies the the inner value is indeed an array.

Fixes #5655


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Fn.join has an optimization to flatten nested joins with the same delimiter:

    Fn.join(",", [ Fn.join(",", [ "a", "b" ]), "c" ]) == Fn.join(",", [ "a", "b", "c" ])

The logic in `isSplicableFnJoinIntrinsic` checks if the object is an Fn::Join which uses the same delimiter, and then splices (`...`) the inner value onto the outer Fn::Join instead of nesting the inner Fn::Join. This can only work if the inner value is a real array (otherwise, we get `Found non-callable @@iterator`�).

The fix is to add an additional check to `isSplicableFnJoinIntrinsic` which verifies the the inner value is indeed an array.

Fixes #5655
@eladb eladb requested a review from rix0rrr January 7, 2020 08:24
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jan 7, 2020
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Jan 7, 2020

Thank you for contributing! Your pull request is now being automatically merged.

@mergify mergify bot merged commit 24ded60 into master Jan 7, 2020
@mergify mergify bot deleted the benisrae/fix-fnjoin-splicable branch January 7, 2020 09:16
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.

Nested Fn::Join doesn't work with Fn::Split
3 participants