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

Backport of Plan renderer: Support users indexing integer paths with stringified numbers into v1.5 #33476

Merged

Conversation

teamterraform
Copy link
Contributor

Backport

This PR is auto-generated from #33475 to be assessed for backporting due to the inclusion of the label 1.5-backport.

The below text is copied from the body of the original PR.


Terraform allows users to specify indexes as strings as long as the string can be converted into a number. For example, the following are equivalent:

  • test_resource.resource.list[0].attribute
  • test_resource.resource.list["0"].attribute
  • test_resource.resource.list["0.0"].attribute

While the following would all raise validation errors.

  • test_resource.resource.list[0.5].attribute
  • test_resource.resource.list["not a number"].attribute
  • test_resource.resource.list["0.5"].attribute

The plan renderer currently makes an assumption that the indices will be the appropriate type. This causes a panic when attributes like those listed above are included in the relevant attributes data, as the renderer will attempt to cast them into the wrong type.

This PR updates the logic for parsing paths within the renderer so that it will attempt to convert strings into integers and panic if it can't. The panic should be okay and never triggered as Terraform will fail earlier if the index is actually invalid.

Fixes #33472

Target Release

1.5.3

Draft CHANGELOG entry

BUG FIXES

  • Fixes crash when rendering the plan if a relevant attribute contains an integer index specified as a string.

@teamterraform teamterraform force-pushed the backport/liamcervante/33472/endlessly-neutral-mustang branch 2 times, most recently from 5acec44 to a0cd30b Compare July 5, 2023 09:11
@liamcervante liamcervante merged commit bfce17f into v1.5 Jul 5, 2023
6 checks passed
@liamcervante liamcervante deleted the backport/liamcervante/33472/endlessly-neutral-mustang branch July 5, 2023 09:20
@github-actions
Copy link

github-actions bot commented Jul 5, 2023

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants