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

Cannot perform any Terraform action (plan, apply) when TF state contains a computed element of type: schema.TypeMap with a key containing a dot #1370

Closed
dwalasek opened this issue Sep 2, 2024 · 1 comment
Labels
bug Something isn't working terraform-plugin-framework Resolved in terraform-plugin-framework

Comments

@dwalasek
Copy link

dwalasek commented Sep 2, 2024

SDK version

v2.34.0

Relevant provider source code

The problem occurs if we have field defined as Computed and of Type: schema.TypeMap, like:

"test": {
				Type:        schema.TypeMap,
				Computed:    true,
				Elem: &schema.Schema{
					Type: schema.TypeInt,
				},
			}

And when key of this element contains dot and it's stored in state, like:

            "test": {
              "foo": 1000,
              "foo.bar": 1000
            },

Terraform Configuration Files

terraform {
  required_providers {
    signalfx = {
      source = "splunk-terraform/signalfx"
   }
  }
}


provider "signalfx" {
}

resource "signalfx_detector" "d" {
  name = "testing terraform"
  program_text = <<-EOT
detect(when(const(0) > const(1))).publish('foo')
detect(when(const(0) > const(1))).publish('foo.bar')
EOT

  rule {
    detect_label = "foo"
    parameterized_body = "#"
    severity = "Info"
  }
  rule {
    detect_label = "foo.bar"
    parameterized_body = "#"
    severity = "Info"
  }
}

Debug Output

Following exception is thrown:

goroutine 15 [running]:
github.com/hashicorp/terraform-plugin-sdk/v2/terraform.(*ResourceConfig).get(0x14000272cd0, {0x1400049c760, 0x1b}, 0x140000bbb60)
        /Users/dwalasek/go/src/github.com/splunk-terraform/terraform-provider-signalfx/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/terraform/resource.go:335 +0x7b0
github.com/hashicorp/terraform-plugin-sdk/v2/terraform.(*ResourceConfig).IsComputed(0x14000272cd0, {0x1400049c760, 0x1b})
        /Users/dwalasek/go/src/github.com/splunk-terraform/terraform-provider-signalfx/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/terraform/resource.go:248 +0x50
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*ConfigFieldReader).readMap(0x140001de6f0, {0x10170fc85, 0x11}, 0x14000502000)
        /Users/dwalasek/go/src/github.com/splunk-terraform/terraform-provider-signalfx/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/field_reader_config.go:192 +0xa84
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*ConfigFieldReader).readField(0x140001de6f0, {0x14000409080, 0x1, 0x1}, 0x0)
        /Users/dwalasek/go/src/github.com/splunk-terraform/terraform-provider-signalfx/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/field_reader_config.go:108 +0x91c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*ConfigFieldReader).ReadField(0x140001de6f0, {0x14000409080, 0x1, 0x1})
        /Users/dwalasek/go/src/github.com/splunk-terraform/terraform-provider-signalfx/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/field_reader_config.go:32 +0xa8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*MultiLevelFieldReader).ReadFieldExact(0x1400029d6e0, {0x14000409080, 0x1, 0x1}, {0x101706390, 0x6})
        /Users/dwalasek/go/src/github.com/splunk-terraform/terraform-provider-signalfx/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/field_reader_multi.go:34 +0xec
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*ResourceData).get(0x140003ef580, {0x14000409080, 0x1, 0x1}, 0x2)
        /Users/dwalasek/go/src/github.com/splunk-terraform/terraform-provider-signalfx/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/resource_data.go:551 +0x1a0
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*ResourceData).getChange(0x140003ef580, {0x10170fc85, 0x11}, 0x1, 0x12)
        /Users/dwalasek/go/src/github.com/splunk-terraform/terraform-provider-signalfx/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/resource_data.go:527 +0x11c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*ResourceData).diffChange(0x140003ef580, {0x10170fc85, 0x11})
        /Users/dwalasek/go/src/github.com/splunk-terraform/terraform-provider-signalfx/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/resource_data.go:504 +0x70
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.diffMap(0x140003d7b00, {0x10170fc85, 0x11}, 0x14000502000, 0x140003e17b8, {0x1019a1c78, 0x140003ef580}, 0x0)
        /Users/dwalasek/go/src/github.com/splunk-terraform/terraform-provider-signalfx/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/schema.go:1302 +0x104
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.diff(0x140003d7b00, {0x10199f3a0, 0x140002cf0b0}, {0x10170fc85, 0x11}, 0x14000502000, 0x140003ef500, {0x1019a1c78, 0x140003ef580}, 0x0)
        /Users/dwalasek/go/src/github.com/splunk-terraform/terraform-provider-signalfx/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/schema.go:1132 +0x1a0
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.Diff(0x140003d7b00, {0x10199f3a0, 0x140002cf0b0}, 0x140003d2c30, 0x14000272cd0, 0x1400045e960, {0x1018297c0, 0x140000a7e80}, 0x0)
        /Users/dwalasek/go/src/github.com/splunk-terraform/terraform-provider-signalfx/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/schema.go:678 +0x408
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).SimpleDiff(0x140004736c0, {0x10199f3a0, 0x140002cf0b0}, 0x140003d2c30, 0x14000272cd0, {0x1018297c0, 0x140000a7e80})
        /Users/dwalasek/go/src/github.com/splunk-terraform/terraform-provider-signalfx/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/resource.go:962 +0x8c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).PlanResourceChange(0x140005b0000, {0x10199f3a0, 0x140002cf0b0}, 0x14000059130)
        /Users/dwalasek/go/src/github.com/splunk-terraform/terraform-provider-signalfx/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/grpc_provider.go:792 +0xf54
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).PlanResourceChange(0x140005b4000, {0x10199f3a0, 0x140002cef30}, 0x140002a8ee0)
        /Users/dwalasek/go/src/github.com/splunk-terraform/terraform-provider-signalfx/vendor/github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server/server.go:824 +0x584
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_PlanResourceChange_Handler({0x101962440, 0x140005b4000}, {0x10199f3a0, 0x140002ce270}, 0x140002a8e70, 0x0)
        /Users/dwalasek/go/src/github.com/splunk-terraform/terraform-provider-signalfx/vendor/github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:449 +0x28c
google.golang.org/grpc.(*Server).processUnaryRPC(0x140002921e0, {0x1019a29c0, 0x14000490d00}, 0x140003d8b40, 0x1400058e8a0, 0x101ef2a60, 0x0)
        /Users/dwalasek/go/src/github.com/splunk-terraform/terraform-provider-signalfx/vendor/google.golang.org/grpc/server.go:1358 +0x1260
google.golang.org/grpc.(*Server).handleStream(0x140002921e0, {0x1019a29c0, 0x14000490d00}, 0x140003d8b40, 0x0)
        /Users/dwalasek/go/src/github.com/splunk-terraform/terraform-provider-signalfx/vendor/google.golang.org/grpc/server.go:1735 +0x71c
google.golang.org/grpc.(*Server).serveStreams.func1.1()
        /Users/dwalasek/go/src/github.com/splunk-terraform/terraform-provider-signalfx/vendor/google.golang.org/grpc/server.go:970 +0x118
created by google.golang.org/grpc.(*Server).serveStreams.func1 in goroutine 41
        /Users/dwalasek/go/src/github.com/splunk-terraform/terraform-provider-signalfx/vendor/google.golang.org/grpc/server.go:981 +0x1fc

Expected Behavior

Terraform SDK should be able to parse a state with element of schema.TypeMap with a key containing a dot

Actual Behavior

Terraform SDK is not able to parse a state with element of schema.TypeMap with a key containing a dot... and all subsequent call for plan, apply is failing

Steps to Reproduce

  1. Use terraform code from section: Terraform Configuration Files
  2. Terraform init
  3. Terraform plan (it ends with success)
  4. Terraform apply (it ends with success)
  5. All subsequent action for terraform plan/apply end with failure like mentioned above
@dwalasek dwalasek added the bug Something isn't working label Sep 2, 2024
@austinvalle
Copy link
Member

Quick drive-by comment 🚗 , this is a duplicate of a known issue (#658) and is fixed/fully supported in terraform-plugin-framework

@austinvalle austinvalle closed this as not planned Won't fix, can't repro, duplicate, stale Sep 10, 2024
@austinvalle austinvalle added the terraform-plugin-framework Resolved in terraform-plugin-framework label Sep 10, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working terraform-plugin-framework Resolved in terraform-plugin-framework
Projects
None yet
Development

No branches or pull requests

2 participants