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

panic on passing non-string key to map() #23043

Closed
alxrem opened this issue Oct 9, 2019 · 3 comments · Fixed by #24277
Closed

panic on passing non-string key to map() #23043

alxrem opened this issue Oct 9, 2019 · 3 comments · Fixed by #24277
Labels
bug config crash v0.12 Issues (primarily bugs) reported against v0.12 releases

Comments

@alxrem
Copy link

alxrem commented Oct 9, 2019

Terraform Version

Terraform v0.12.10
+ provider.local v1.3.0

Terraform Configuration Files

locals {
	a = map(1, 1)
}

Debug Output

https://gist.github.com/alxrem/16972d40bbfe8df2fbecac6720a9b5a8

Crash Output

https://gist.github.com/alxrem/af55977e452fbd3c6be0c192c05bc3bd

Expected Behavior

Error message from syntax parser.

Actual Behavior

Panic

Steps to Reproduce

cat <<EOF >bug.tf
locals {
	a = map(1, 1)
}
EOF
terraform init
terraform plan
@hashibot hashibot added bug config crash v0.12 Issues (primarily bugs) reported against v0.12 releases labels Oct 9, 2019
@mjgpy3
Copy link

mjgpy3 commented Oct 15, 2019

@alxrem this function appears to be depreciated in terraform 0.12: https://www.terraform.io/docs/configuration/functions/map.html

@alxrem
Copy link
Author

alxrem commented Oct 16, 2019

Thank you. I don't use it, only reported the noticed bug.

alisdair added a commit that referenced this issue Mar 4, 2020
The map function assumed that the key arguments were strings, and would
panic if they were not.

After this commit, calling `map(1, 2)` will result in a map `{"1" = 1}`,
and calling `map(null, 1)` will result in a syntax error.

Fixes #23346, fixes #23043
alisdair added a commit that referenced this issue Mar 4, 2020
The map function assumed that the key arguments were strings, and would
panic if they were not.

After this commit, calling `map(1, 2)` will result in a map `{"1" = 1}`,
and calling `map(null, 1)` will result in a syntax error.

Fixes #23346, fixes #23043
@ghost
Copy link

ghost commented Apr 4, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 4, 2020
noahmercado pushed a commit to noahmercado/terraform that referenced this issue Apr 8, 2020
The map function assumed that the key arguments were strings, and would
panic if they were not.

After this commit, calling `map(1, 2)` will result in a map `{"1" = 1}`,
and calling `map(null, 1)` will result in a syntax error.

Fixes hashicorp#23346, fixes hashicorp#23043
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug config crash v0.12 Issues (primarily bugs) reported against v0.12 releases
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants