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

Crashing on aws_dynamodb_table_item wrong data type #25540

Closed
ChristophShyper opened this issue Jul 10, 2020 · 3 comments
Closed

Crashing on aws_dynamodb_table_item wrong data type #25540

ChristophShyper opened this issue Jul 10, 2020 · 3 comments
Labels
bug config crash v0.12 Issues (primarily bugs) reported against v0.12 releases waiting for reproduction unable to reproduce issue without further information

Comments

@ChristophShyper
Copy link

Terraform Version

0.12.26

Terraform Configuration Files

variable "users" {
  type        = list(string)
  default     = []
}

resource "aws_dynamodb_table_item" "this" {
  table_name = "table_name"
  hash_key   = "item"
  item = jsonencode({
    item = { S = "item_path" }
    parameters = { M = {
    users = { S = var.users }
      }
    }
  })
}

Debug Output

panic: inconsistent map element types (cty.Object(map[string]cty.Type{"S":cty.DynamicPseudoType}) then cty.Object(map[string]cty.Type{"S":cty.String}))

goroutine 276 [running]:
github.com/zclconf/go-cty/cty.MapVal(0xc000949458, 0xc000949400, 0xc0000b5270, 0x8, 0xc00061a868)
	/opt/teamcity-agent/work/9e329aa031982669/pkg/mod/github.com/zclconf/go-cty@v1.2.1/cty/value_init.go:207 +0x538
github.com/zclconf/go-cty/cty/convert.conversionObjectToMap.func2(0x246a000, 0xc00056c700, 0x1bd0d80, 0xc00157e810, 0xc001731b90, 0x1, 0x1, 0xc000492000, 0x10, 0x10, ...)
	/opt/teamcity-agent/work/9e329aa031982669/pkg/mod/github.com/zclconf/go-cty@v1.2.1/cty/convert/conversion_collection.go:338 +0x555
github.com/zclconf/go-cty/cty/convert.getConversion.func1(0x246a000, 0xc00056c700, 0x1bd0d80, 0xc00157e810, 0x0, 0x0, 0x0, 0xc0016f8f30, 0xc001731b80, 0x2469fc0, ...)
	/opt/teamcity-agent/work/9e329aa031982669/pkg/mod/github.com/zclconf/go-cty@v1.2.1/cty/convert/conversion.go:46 +0x1ad
github.com/zclconf/go-cty/cty/convert.retConversion.func1(0x246a000, 0xc00056c700, 0x1bd0d80, 0xc00157e810, 0xc001731b80, 0x0, 0x0, 0x0, 0x0, 0x0)
	/opt/teamcity-agent/work/9e329aa031982669/pkg/mod/github.com/zclconf/go-cty@v1.2.1/cty/convert/conversion.go:179 +0x6b
github.com/zclconf/go-cty/cty/convert.Convert(0x246a000, 0xc00056c700, 0x1bd0d80, 0xc00157e810, 0x2469fc0, 0xc00014f000, 0x0, 0x246a000, 0xc00056c700, 0x1bd0d80, ...)
	/opt/teamcity-agent/work/9e329aa031982669/pkg/mod/github.com/zclconf/go-cty@v1.2.1/cty/convert/public.go:51 +0x1af
github.com/hashicorp/terraform/terraform.(*EvalModuleCallArgument).Eval(0xc00082d700, 0x249fe60, 0xc0015cc750, 0x2, 0x2, 0xc000968000, 0x42)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/eval_variable.go:77 +0x160
github.com/hashicorp/terraform/terraform.EvalRaw(0x2424a20, 0xc00082d700, 0x249fe60, 0xc0015cc750, 0x2d, 0x0, 0x0, 0x2d)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/eval.go:57 +0x131
github.com/hashicorp/terraform/terraform.(*EvalOpFilter).Eval(0xc0012756e0, 0x249fe60, 0xc0015cc750, 0x2, 0x2, 0xc000916b38, 0x42b8a1)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/eval_filter_operation.go:37 +0x4c
github.com/hashicorp/terraform/terraform.EvalRaw(0x2424a60, 0xc0012756e0, 0x249fe60, 0xc0015cc750, 0x14, 0xbfba2e7bdfb3ebc8, 0x14fcf24ad, 0x2d)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/eval.go:57 +0x131
github.com/hashicorp/terraform/terraform.(*EvalSequence).Eval(0xc0005d9f40, 0x249fe60, 0xc0015cc750, 0x2, 0x2, 0xf3e5f5, 0x2425100)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/eval_sequence.go:20 +0xfd
github.com/hashicorp/terraform/terraform.EvalRaw(0x2424bc0, 0xc0005d9f40, 0x249fe60, 0xc0015cc750, 0x1bc1420, 0x3547785, 0x1b24b60, 0xc001731660)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/eval.go:57 +0x131
github.com/hashicorp/terraform/terraform.Eval(0x2424bc0, 0xc0005d9f40, 0x249fe60, 0xc0015cc750, 0xc0005d9f40, 0x2424bc0, 0xc0005d9f40, 0x0)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/eval.go:35 +0x4d
github.com/hashicorp/terraform/terraform.(*Graph).walk.func1(0x1d8e520, 0xc00082d300, 0x0, 0x0, 0x0)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/graph.go:90 +0xf40
github.com/hashicorp/terraform/dag.(*Walker).walkVertex(0xc0001df880, 0x1d8e520, 0xc00082d300, 0xc00067f700)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/dag/walk.go:392 +0x353
created by github.com/hashicorp/terraform/dag.(*Walker).Update
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/dag/walk.go:314 +0xa9b



!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Crash Output

2020/07/10 10:24:37 [TRACE] [walkValidate] Entering eval tree: aws_dynamodb_table_item.this
panic: inconsistent map element types (cty.Object(map[string]cty.Type{"S":cty.String}) then cty.Object(map[string]cty.Type{"S":cty.DynamicPseudoType}))

goroutine 235 [running]:
github.com/zclconf/go-cty/cty.MapVal(0xc0007d5458, 0xc0007d5400, 0xc0000b5250, 0x8, 0xc000df79c8)
	/opt/teamcity-agent/work/9e329aa031982669/pkg/mod/github.com/zclconf/go-cty@v1.2.1/cty/value_init.go:207 +0x538
github.com/zclconf/go-cty/cty/convert.conversionObjectToMap.func2(0x246a000, 0xc000a06730, 0x1bd0d80, 0xc0014c5920, 0xc001986790, 0x1, 0x1, 0xc000696380, 0x10, 0x10, ...)
	/opt/teamcity-agent/work/9e329aa031982669/pkg/mod/github.com/zclconf/go-cty@v1.2.1/cty/convert/conversion_collection.go:338 +0x555
github.com/zclconf/go-cty/cty/convert.getConversion.func1(0x246a000, 0xc000a06730, 0x1bd0d80, 0xc0014c5920, 0x0, 0x0, 0x0, 0xc001acb380, 0xc001986780, 0x2469fc0, ...)
	/opt/teamcity-agent/work/9e329aa031982669/pkg/mod/github.com/zclconf/go-cty@v1.2.1/cty/convert/conversion.go:46 +0x1ad
github.com/zclconf/go-cty/cty/convert.retConversion.func1(0x246a000, 0xc000a06730, 0x1bd0d80, 0xc0014c5920, 0xc001986780, 0x0, 0x0, 0x0, 0x0, 0x0)
	/opt/teamcity-agent/work/9e329aa031982669/pkg/mod/github.com/zclconf/go-cty@v1.2.1/cty/convert/conversion.go:179 +0x6b
github.com/zclconf/go-cty/cty/convert.Convert(0x246a000, 0xc000a06730, 0x1bd0d80, 0xc0014c5920, 0x2469fc0, 0xc00022e460, 0x0, 0x246a000, 0xc000a06730, 0x1bd0d80, ...)
	/opt/teamcity-agent/work/9e329aa031982669/pkg/mod/github.com/zclconf/go-cty@v1.2.1/cty/convert/public.go:51 +0x1af
github.com/hashicorp/terraform/terraform.(*EvalModuleCallArgument).Eval(0xc00007cb00, 0x249fe60, 0xc0008b7110, 0x2, 0x2, 0xc0005fc000, 0x42)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/eval_variable.go:77 +0x160
github.com/hashicorp/terraform/terraform.EvalRaw(0x2424a20, 0xc00007cb00, 0x249fe60, 0xc0008b7110, 0x2d, 0x0, 0x0, 0x2d)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/eval.go:57 +0x131
github.com/hashicorp/terraform/terraform.(*EvalOpFilter).Eval(0xc001a1c2a0, 0x249fe60, 0xc0008b7110, 0x2, 0x2, 0xc0007bdb38, 0x42b8a1)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/eval_filter_operation.go:37 +0x4c
github.com/hashicorp/terraform/terraform.EvalRaw(0x2424a60, 0xc001a1c2a0, 0x249fe60, 0xc0008b7110, 0x14, 0xbfba2e5951b6757c, 0x157ced6d5, 0x2d)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/eval.go:57 +0x131
github.com/hashicorp/terraform/terraform.(*EvalSequence).Eval(0xc001207980, 0x249fe60, 0xc0008b7110, 0x2, 0x2, 0xf3e5f5, 0x2425100)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/eval_sequence.go:20 +0xfd
github.com/hashicorp/terraform/terraform.EvalRaw(0x2424bc0, 0xc001207980, 0x249fe60, 0xc0008b7110, 0x1bc1420, 0x3547785, 0x1b24b60, 0xc0019861d0)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/eval.go:57 +0x131
github.com/hashicorp/terraform/terraform.Eval(0x2424bc0, 0xc001207980, 0x249fe60, 0xc0008b7110, 0xc001207980, 0x2424bc0, 0xc001207980, 0x0)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/eval.go:35 +0x4d
github.com/hashicorp/terraform/terraform.(*Graph).walk.func1(0x1d8e520, 0xc00025fb80, 0x0, 0x0, 0x0)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/graph.go:90 +0xf40
github.com/hashicorp/terraform/dag.(*Walker).walkVertex(0xc000510d80, 0x1d8e520, 0xc00025fb80, 0xc001244080)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/dag/walk.go:392 +0x353
created by github.com/hashicorp/terraform/dag.(*Walker).Update
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/dag/walk.go:314 +0xa9b

Expected Behavior

It should return some error message about wrong type.
Exception is not caught properly.
Remote state lock should be released.

Actual Behavior

Run is crushing and remote state lock is not released.
Similar data type problems were handled properly, don't remember specific configuration, but passed as local.something.
Probably the key is using default value for the variable.

Steps to Reproduce

  1. terraform init
  2. terraform plan

Additional Context

References

@jbardin jbardin added bug config v0.12 Issues (primarily bugs) reported against v0.12 releases labels Jul 10, 2020
@danieldreier
Copy link
Contributor

@ChristophShyper I have tried to reproduce this but have not been able to. I put the reproduction case you made up on https://github.com/danieldreier/terraform-issue-reproductions/tree/master/25540 just to show exactly what I'm doing. When I run terraform plan I get the following error:

Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.


------------------------------------------------------------------------

Error: Invalid format of "item": Decoding failed: json: cannot unmarshal array into Go struct field AttributeValue.M.S of type string

  on repro.tf line 13, in resource "aws_dynamodb_table_item" "this":
  13:   item = jsonencode({
  14:     item = { S = "item_path" }
  15:     parameters = { M = {
  16:     users = { S = var.users }
  17:       }
  18:     }
  19:   })

Do you have any other context you can provide? Based on the error you've showed this looks like a real problem, but I don't know how to reproduce it, so there's not much we can do to fix it.

@danieldreier danieldreier added the waiting for reproduction unable to reproduce issue without further information label Sep 29, 2020
@ChristophShyper
Copy link
Author

I guess this has been fixed somewhere during last months. I've also noticed that now empty strings can be safely entered and read from DynamoDB, which wasn't possible before.

@ghost
Copy link

ghost commented Oct 30, 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.

@hashicorp hashicorp locked as resolved and limited conversation to collaborators Oct 30, 2020
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 waiting for reproduction unable to reproduce issue without further information
Projects
None yet
Development

No branches or pull requests

3 participants