Skip to content

fix(cloudformation-include): TypeError when including template with intrinsic functions#36157

Merged
mergify[bot] merged 3 commits intomainfrom
mrgrain/fix/l1-relationshipts-forEach
Nov 24, 2025
Merged

fix(cloudformation-include): TypeError when including template with intrinsic functions#36157
mergify[bot] merged 3 commits intomainfrom
mrgrain/fix/l1-relationshipts-forEach

Conversation

@mrgrain
Copy link
Copy Markdown
Contributor

@mrgrain mrgrain commented Nov 22, 2025

Issue # (if applicable)

Closes #36140

Reason for this change

In #35838 we introduced typed relationships for L1 constructs. For properties with arrays, this incorrectly assumed that the value could not be a token. But it can and especially when using the cloudformation-include module.

Description of changes

Adds a check to ensure the value is not a Token, which cannot be used as an array, despite passing the type check.

There are two places in resolver-builder.ts where we added a .forEach(). The first one is fixed in this PR, second location already has a check for a resolvable.

Note we are only checking for a resolvable here, not if the value is actually an array. At some point this could extended to also check for an array, likely with some refactoring of the "in-place" mapping into a helper function (the currently generated code is very unreadable). For this PR I have chosen to do the minimal change.

Describe any new or updated permissions being added

n/a

Description of how you validated changes

Added a new unit test for this case.

Checklist


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

@github-actions github-actions bot added bug This issue is a bug. effort/medium Medium work item – several days of effort p0 labels Nov 22, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team November 22, 2025 17:08
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Nov 22, 2025
Copy link
Copy Markdown
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

(This review is outdated)

@mrgrain
Copy link
Copy Markdown
Contributor Author

mrgrain commented Nov 22, 2025

Change here:

`(props.${name}?.forEach((item: ${propType.arrayOfType!.toString()}, i: number, arr: ${propType.toString()}) => { arr[i] = ${buildChain('item')}; }), props.${name} as ${resolvableType.toString()})`,

? expr.directCode(`props.${name}.forEach((item: any, i: number, arr: any[]) => { arr[i] = ${functionName}(item) }), props.${name}`)

@mrgrain mrgrain added effort/small Small work item – less than a day of effort and removed effort/medium Medium work item – several days of effort labels Nov 23, 2025
@github-actions github-actions bot added effort/medium Medium work item – several days of effort and removed effort/small Small work item – less than a day of effort labels Nov 23, 2025
@mrgrain mrgrain changed the title fix(cloudformation-include): TypeError when including template with intrinsic functions fix(cloudformation-include): TypeError when including template with intrinsic functions Nov 24, 2025
@mrgrain mrgrain added pr-linter/exempt-test The PR linter will not require test changes pr-linter/exempt-integ-test The PR linter will not require integ test changes and removed pr-linter/exempt-test The PR linter will not require test changes labels Nov 24, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review November 24, 2025 07:57

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@Abogical Abogical added the priority-pr push the PR to priority squash queue label Nov 24, 2025
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Nov 24, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 4ee69b7 into main Nov 24, 2025
48 of 49 checks passed
@mergify mergify bot deleted the mrgrain/fix/l1-relationshipts-forEach branch November 24, 2025 08:36
@github-actions
Copy link
Copy Markdown
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug This issue is a bug. contribution/core This is a PR that came from AWS. effort/medium Medium work item – several days of effort p0 pr-linter/exempt-integ-test The PR linter will not require integ test changes priority-pr push the PR to priority squash queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cloudformation_include: TypeError when Lambda Layers defined with Condition in template

5 participants