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

Return error when the template's single interpolation results in null value #36658

Merged
merged 3 commits into from
Mar 10, 2025

Conversation

dsa0x
Copy link
Member

@dsa0x dsa0x commented Mar 10, 2025

Fixes #36652

When a string interpolation contains only one expression sequence, HCL optimizes by wrapping and directly delegating evaluation to that expression. The templatestring function tries to refine the expression value as non-null, and if null, this refinement leads to a panic. For compatibility reasons, HCL has to continue to support this unwrapping logic (See attempted PR), thus we will simply return an error in templatestring when the single evaluated expression is null

Target Release

1.12.x

CHANGELOG entry

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.

@dsa0x dsa0x marked this pull request as ready for review March 10, 2025 08:59
@dsa0x dsa0x requested a review from a team as a code owner March 10, 2025 08:59
SarahFrench
SarahFrench previously approved these changes Mar 10, 2025
@@ -0,0 +1,5 @@
kind: BUG FIXES
body: Return error when the template's single interpolation results in null value
Copy link
Member

Choose a reason for hiding this comment

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

Could you please update the change file to mention the templatestring function?

@dsa0x dsa0x merged commit 08fa94c into main Mar 10, 2025
8 checks passed
@dsa0x dsa0x deleted the sams/fix-single-wrapped-null branch March 10, 2025 11:38
@dsa0x dsa0x added the 1.11-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged label Mar 10, 2025
Copy link
Contributor

Changelog Warning

Currently this PR would target a v1.11 release. Please add a changelog entry for in the .changes/v1.11 folder, or discuss which release you'd like to target with your reviewer. If you believe this change does not need a changelog entry, please add the 'no-changelog-needed' label.

@dbanck
Copy link
Member

dbanck commented Mar 10, 2025

Heads up, the changelog for this change has ended up in the wrong folder and wrong branch. Since it was backported to 1.11, there should only be a changelog file on the v1.11 branch in the .changes/1.11 directory. None on main

@dsa0x
Copy link
Member Author

dsa0x commented Mar 10, 2025

Thanks @dbanck. I'll move appropriately

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.11-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

templatestring Function Crashes When Map Contains a Key Mapped to null
3 participants