-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
core: fix crash when computed nested map given in module block #13343
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a minor code style comment, otherwise LGTM!
@@ -114,7 +114,6 @@ type EvalVariableBlock struct { | |||
VariableValues map[string]interface{} | |||
} | |||
|
|||
// TODO: test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love seeing these go away
terraform/eval_variable.go
Outdated
@@ -175,14 +174,22 @@ func (n *EvalVariableBlock) setUnknownVariableValueForPath(path string) error { | |||
var current interface{} = n.VariableValues[pathComponents[0]] | |||
for i := 1; i < len(pathComponents); i++ { | |||
switch current.(type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could define switch tCurrent := current.(type) {
here, and get rid of the redundant assertions below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, good point! I will update this before merging.
This crash resulted because the type switch checked for either of two types but the type assertion within it assumed only one of them. A straightforward (if inelegant) fix is to simply duplicate the relevant case block and change the type assertion, thus allowing the types to match up in all cases. This fixes #13297.
This previously lacked tests altogether. This new test verifies the "happy path", ensuring that both literal and computed values pass through correctly into the VariableValues map.
acd225f
to
df4c0a0
Compare
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
This crash resulted because the type switch checked for either of two types but the type assertion within it assumed only one of them.
A straightforward (if inelegant) fix is to simply duplicate the relevant case block and change the type assertion, thus allowing the types to match up in all cases.
This fixes #13297.
(Also includes a basic test for this eval type, since it entirely lacked one before.)