hashicorp / hashicorp/terraform-plugin-sdk
Panic when parsing map of integer with periods in names
- Dominant language
- Go
- Stars
- 485
- Forks
- 244
- Avg merge
- 19h 57m
- Merged PRs (30d)
- 4
Description
### SDK version
```
1.15
```
### Terraform Configuration Files
```hcl
resource "datadog_monitor" "issue_781" {
name = "vault is unreachable {{url.name}} {{check_message}}"
type = "service check"
query = "\"http.can_connect\".over(\"cluster_type:kubernetes\",\"instance:vault\").by(\"url\",\"cluster_name\").last(1).pct_by_status()"
message = "Placeholder"
thresholds = {
critical = 50
}
tags = ["creator:terraform"]
no_data_timeframe = 0
silenced = {
"cluster_name:testeks" = 0
"cluster_name:testeks.example.com" = 0
}
}
```
### Debug Output
```
2020-12-11T10:00:58.416+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: panic: Unknown kind: int
2020-12-11T10:00:58.416+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1:
2020-12-11T10:00:58.416+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: goroutine 83 [running]:
2020-12-11T10:00:58.416+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk/terraform.(*ResourceConfig).get(0xc0005aaab0, 0xc0006fd620, 0x2d, 0xc0005aaae0, 0xc0006fd620, 0x2d, 0x2)
2020-12-11T10:00:58.416+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk@v1.15.0/terraform/resource.go:492 +0xa25
2020-12-11T10:00:58.416+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk/terraform.(*ResourceConfig).IsComputed(0xc0005aaab0, 0xc0006fd620, 0x2d, 0x2)
2020-12-11T10:00:58.416+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk@v1.15.0/terraform/resource.go:383 +0x4c
2020-12-11T10:00:58.416+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ConfigFieldReader).readMap(0xc0005aadb0, 0x20e9eb5, 0x8, 0xc0002f92c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
2020-12-11T10:00:58.416+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk@v1.15.0/helper/schema/field_reader_config.go:214 +0x6e8
2020-12-11T10:00:58.416+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ConfigFieldReader).readField(0xc0005aadb0, 0xc0004cfd70, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
2020-12-11T10:00:58.416+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk@v1.15.0/helper/schema/field_reader_config.go:130 +0xa29
2020-12-11T10:00:58.416+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ConfigFieldReader).ReadField(0xc0005aadb0, 0xc0004cfd70, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0005ca840, ...)
2020-12-11T10:00:58.416+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk@v1.15.0/helper/schema/field_reader_config.go:28 +0xae
2020-12-11T10:00:58.416+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*MultiLevelFieldReader).ReadFieldExact(0xc0004c30a0, 0xc0004cfd70, 0x1, 0x1, 0x20e6e36, 0x6, 0x0, 0x0, 0x0, 0x0, ...)
2020-12-11T10:00:58.416+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk@v1.15.0/helper/schema/field_reader_multi.go:31 +0xd0
2020-12-11T10:00:58.416+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ResourceData).get(0xc0006e7c70, 0xc0004cfd70, 0x1, 0x1, 0x12, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
2020-12-11T10:00:58.416+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk@v1.15.0/helper/schema/resource_data.go:532 +0xfa
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ResourceData).getChange(0xc0006e7c70, 0x20e9eb5, 0x8, 0x1e61201, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk@v1.15.0/helper/schema/resource_data.go:508 +0x125
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ResourceData).diffChange(0xc0006e7c70, 0x20e9eb5, 0x8, 0x20e4295, 0x1, 0xc00038f1f0, 0x9, 0x1e6d180)
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk@v1.15.0/helper/schema/resource_data.go:485 +0x97
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk/helper/schema.schemaMap.diffMap(0xc00011baa0, 0x20e9eb5, 0x8, 0xc0002f92c0, 0xc00038f4d8, 0x2371ea0, 0xc0006e7c70, 0xc71d4b00, 0x0, 0x0)
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk@v1.15.0/helper/schema/schema.go:1119 +0xf7
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk/helper/schema.schemaMap.diff(0xc00011baa0, 0x20e9eb5, 0x8, 0xc0002f92c0, 0xc0004c2f60, 0x2371ea0, 0xc0006e7c70, 0x110a500, 0x0, 0x0)
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk@v1.15.0/helper/schema/schema.go:956 +0x5c8
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk/helper/schema.schemaMap.Diff(0xc00011baa0, 0xc000250460, 0xc0005aaab0, 0x21f9138, 0x1f040a0, 0xc0005a0000, 0x0, 0x0, 0x236cee0, 0x0)
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk@v1.15.0/helper/schema/schema.go:506 +0x219
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).simpleDiff(0xc0002e5b90, 0xc000250460, 0xc0005aaab0, 0x1f040a0, 0xc0005a0000, 0xc0005aaa01, 0x0, 0x0)
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk@v1.15.0/helper/schema/resource.go:356 +0x85
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).SimpleDiff(0xc0000a8000, 0xc00096da70, 0xc000250460, 0xc0005aaab0, 0xc000714c00, 0xc0005aaab0, 0x0)
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk@v1.15.0/helper/schema/provider.go:321 +0x99
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).PlanResourceChange(0xc0001201e8, 0x236c320, 0xc000714ba0, 0xc0006e7730, 0xc0001201e8, 0xc000714ba0, 0xc00056eb78)
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk@v1.15.0/internal/helper/plugin/grpc_provider.go:633 +0x785
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_PlanResourceChange_Handler(0x2080fa0, 0xc0001201e8, 0x236c320, 0xc000714ba0, 0xc000916f00, 0x0, 0x236c320, 0xc000714ba0, 0xc0001ed500, 0x6fa)
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: github.com/hashicorp/terraform-plugin-sdk@v1.15.0/internal/tfplugin5/tfplugin5.pb.go:3287 +0x214
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: google.golang.org/grpc.(*Server).processUnaryRPC(0xc000642600, 0x2375f20, 0xc000102a80, 0xc000214500, 0xc000714510, 0x2c1e5a8, 0x0, 0x0, 0x0)
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: google.golang.org/grpc@v1.27.1/server.go:1024 +0x522
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: google.golang.org/grpc.(*Server).handleStream(0xc000642600, 0x2375f20, 0xc000102a80, 0xc000214500, 0x0)
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: google.golang.org/grpc@v1.27.1/server.go:1313 +0xd34
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc00054a670, 0xc000642600, 0x2375f20, 0xc000102a80, 0xc000214500)
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: google.golang.org/grpc@v1.27.1/server.go:722 +0xa5
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: created by google.golang.org/grpc.(*Server).serveStreams.func1
2020-12-11T10:00:58.417+0100 [DEBUG] plugin.terraform-provider-datadog_v2.18.1: google.golang.org/grpc@v1.27.1/server.go:720 +0xa5
```
### Expected Behavior
No panic.
### Actual Behavior
Panic. The number of keys in the map seems to matter? Not sure why exactly yet.
### Steps to Reproduce
I'm coming from https://github.com/DataDog/terraform-provider-datadog/issues/781: basically trying to parse a map that looks like this:
```
silenced = {
"foo" = 0
"foo.bar" = 0
}
```
Then
1. `terraform init`
2. `terraform plan`
reproduces the crash.
### References
https://github.com/hashicorp/terraform/pull/7654/ is supposed to handle this case, but I don't understand why it doesn't handle it in the default case, where all types can happen, instead of just the string case.
Contributor guide
Research direction
Start with the panic path in terraform/resource.go and helper/schema/field_reader_config.go, then trace how schema.go handles the reproduced map keys "foo" and "foo.bar". Run the reported terraform init and terraform plan reproduction and compare the behavior with the referenced Terraform pull request. Done means parsing this map completes without a panic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100