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

TF 1.3.2: crash with: inconsistent map element types #31962

Closed
stuart12 opened this issue Oct 7, 2022 · 5 comments
Closed

TF 1.3.2: crash with: inconsistent map element types #31962

stuart12 opened this issue Oct 7, 2022 · 5 comments
Labels
bug waiting for reproduction unable to reproduce issue without further information waiting-response An issue/pull request is waiting for a response from the community

Comments

@stuart12
Copy link

stuart12 commented Oct 7, 2022

Terraform Version

Terraform v1.3.2
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v4.28.0
+ provider registry.terraform.io/hashicorp/null v3.1.1
+ provider registry.terraform.io/hashicorp/template v2.2.0

Terraform Configuration Files

variable "s3" {
  type = map(object({
    name_package_environment_prefix = bool
    name                            = string
    sse_algorithm                   = string
    lifecycle_rule = optional(list(object({
      id      = string
      enabled = bool
      abort_incomplete_multipart_upload_days = optional(number)
      tags                                   = map(string)
      expiration = optional(object({
        days                         = number
        expired_object_delete_marker = bool
      }))
      transition = optional(list(object({
        days          = number
        storage_class = string
      })))
    })), [])
  }))

Debug Output

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

Terraform crashed! This is always indicative of a bug within Terraform.
Please report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version, the stack trace
shown below, and any additional information which may help replicate the issue.

[1]: https://github.com/hashicorp/terraform/issues

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

inconsistent map element types (cty.Object(map[string]cty.Type{"lifecycle_rule":cty.List(cty.ObjectWithOptionalAttrs(map[string]cty.Type{"abort_incomplete_multipart_upload_days":cty.Number, "enabled":cty.Bool, "expiration":cty.Object(map[string]cty.Type{"days":cty.Number, "expired_object_delete_marker":cty.Bool}), "id":cty.String, "tags":cty.Map(cty.String), "transition":cty.List(cty.Object(map[string]cty.Type{"days":cty.Number, "storage_class":cty.String}))}, []string{"abort_incomplete_multipart_upload_days", "expiration", "transition"})), "name":cty.String, "name_package_environment_prefix":cty.Bool, "sse_algorithm":cty.String}) then cty.Object(map[string]cty.Type{"lifecycle_rule":cty.List(cty.Object(map[string]cty.Type{"abort_incomplete_multipart_upload_days":cty.Number, "enabled":cty.Bool, "expiration":cty.Object(map[string]cty.Type{"days":cty.Number, "expired_object_delete_marker":cty.Bool}), "id":cty.String, "tags":cty.Map(cty.String), "transition":cty.List(cty.Object(map[string]cty.Type{"days":cty.Number, "storage_class":cty.String}))})), "name":cty.String, "name_package_environment_prefix":cty.Bool, "sse_algorithm":cty.String}))
goroutine 5071 [running]:
runtime/debug.Stack()
        /usr/local/go/src/runtime/debug/stack.go:24 +0x65
runtime/debug.PrintStack()
        /usr/local/go/src/runtime/debug/stack.go:16 +0x19
github.com/hashicorp/terraform/internal/logging.PanicHandler()
        /home/circleci/project/project/internal/logging/panic.go:55 +0x153
panic({0x21e0160, 0xc0030a9340})
        /usr/local/go/src/runtime/panic.go:884 +0x212
github.com/zclconf/go-cty/cty.MapVal(0xc003b0ac80)
        /home/circleci/go/pkg/mod/github.com/zclconf/go-cty@v1.11.0/cty/value_init.go:221 +0x47f
github.com/zclconf/go-cty/cty.transform({0x0?, 0x0, 0x0}, {{{0x2b66868?, 0xc00164af30?}}, {0x2218580?, 0xc001966270?}}, {0x2b4dc40, 0xc0029e2db8})
        /home/circleci/go/pkg/mod/github.com/zclconf/go-cty@v1.11.0/cty/walk.go:204 +0xc3e
github.com/zclconf/go-cty/cty.TransformWithTransformer(...)
        /home/circleci/go/pkg/mod/github.com/zclconf/go-cty@v1.11.0/cty/walk.go:130
github.com/hashicorp/hcl/v2/ext/typeexpr.(*Defaults).Apply(0xc00148b140?, {{{0x2b66868?, 0xc00164af30?}}, {0x2218580?, 0xc001966270?}})
        /home/circleci/go/pkg/mod/github.com/hashicorp/hcl/v2@v2.14.1/ext/typeexpr/defaults.go:38 +0xa7
github.com/hashicorp/terraform/internal/terraform.prepareFinalInputVariableValue({{0xc001806140, 0x1, 0x1}, {{}, {0xc00069954c, 0x2}}}, 0xc00380da58, 0xc000acab60)
        /home/circleci/project/project/internal/terraform/eval_variable.go:98 +0xacd
github.com/hashicorp/terraform/internal/terraform.(*nodeModuleVariable).evalModuleVariable(0xc001616f00?, {0x2b7cd18?, 0xc0012dc540?}, 0x5d?)
        /home/circleci/project/project/internal/terraform/node_module_variable.go:239 +0x545
github.com/hashicorp/terraform/internal/terraform.(*nodeModuleVariable).Execute(0xc001616f00, {0x2b7cd18, 0xc0012dc540}, 0x2)
        /home/circleci/project/project/internal/terraform/node_module_variable.go:155 +0x172
github.com/hashicorp/terraform/internal/terraform.(*ContextGraphWalker).Execute(0xc0012c6ff0, {0x2b7cd18, 0xc0012dc540}, {0x7f894883e960, 0xc001616f00})
        /home/circleci/project/project/internal/terraform/graph_walk_context.go:136 +0xc2
github.com/hashicorp/terraform/internal/terraform.(*Graph).walk.func1({0x23aeac0, 0xc001616f00})
        /home/circleci/project/project/internal/terraform/graph.go:74 +0x2f0
github.com/hashicorp/terraform/internal/dag.(*Walker).walkVertex(0xc001616f60, {0x23aeac0, 0xc001616f00}, 0xc004b20240)
        /home/circleci/project/project/internal/dag/walk.go:381 +0x2f6
created by github.com/hashicorp/terraform/internal/dag.(*Walker).Update
        /home/circleci/project/project/internal/dag/walk.go:304 +0xf65

Expected Behavior

terraform -chdir=/home/s.pook/git/xxx-dsp-kubernetes/cluster plan -var 'dns={private_zone_name="private.uxbridge.xxx.org",public_zone_name="uxbridge.xxx.org"}' -var s3_kubeconfig_key=dsp-development-k8s-config-uxbridge -var s3_kubeconfig_bucket=k8s-state-store-xxx-development-clusters -var environment=uxbridge -var-file=/home/s.pook/git/xxx-dsp-kubernetes/cluster/development/development.tfvars -compact-warnings should not crash

Actual Behavior

Terraform crashes when I add the [] argument to optional in the second last line of the extract from my terraform configuration given above. If I remove the , [], TF 1.3.2 does not crash.

Steps to Reproduce

terraform -chdir=/home/s.pook/git/xxx-dsp-kubernetes/cluster plan -var 'dns={private_zone_name="private.uxbridge.xxx.org",public_zone_name="uxbridge.xxx.org"}' -var s3_kubeconfig_key=dsp-development-k8s-config-uxbridge -var s3_kubeconfig_bucket=k8s-state-store-xxx-development-clusters -var environment=uxbridge -var-file=/home/s.pook/git/xxx-dsp-kubernetes/cluster/development/development.tfvars -compact-warnings

Additional Context

I'm porting pre-1.3 code that used module_variable_optional_attrs to 1.3. Perhaps the code that is causing terraform 1.3.2 to crash is illegal. I had the same crash with terraform 1.3.1. If I replace the [] with {}, I get the error message: This default value is not compatible with the attribute's type constraint: list of object required. I presume that {} is what I should use as the default value but please correct me if I am wrong. I will provide more information if you ask.

References

I saw #31844 but the fix #31855 targeted 1.3.1 so I should have this fix in TF 1.3.2.

@stuart12 stuart12 added bug new new issue not yet triaged labels Oct 7, 2022
@stuart12
Copy link
Author

stuart12 commented Oct 7, 2022

here are most of the log messages at the info level:

% grep -v 'ReferenceTransformer: reference not found' info.txt | cut -c30-
[INFO]  Terraform version: 1.3.2
[INFO]  Go runtime version: go1.19.1
[INFO]  CLI args: []string{"/home/s.pook/external/tfenv/versions/1.3.2/terraform", "-chdir=/home/s.pook/git/dataseat-dsp-kubernetes/cluster", "plan", "-var", "dns={private_zone_name=\"private.uxbridge.dataseat.org\",public_zone_name=\"uxbridge.dataseat.org\"}", "-var", "s3_kubeconfig_key=dsp-development-k8s-config-uxbridge", "-var", "s3_kubeconfig_bucket=k8s-state-store-dataseat-development-clusters", "-var", "environment=uxbridge", "-var-file=/home/s.pook/git/dataseat-dsp-kubernetes/cluster/development/development.tfvars", "-compact-warnings"}
[INFO]  CLI command args: []string{"plan", "-var", "dns={private_zone_name=\"private.uxbridge.dataseat.org\",public_zone_name=\"uxbridge.dataseat.org\"}", "-var", "s3_kubeconfig_key=dsp-development-k8s-config-uxbridge", "-var", "s3_kubeconfig_bucket=k8s-state-store-dataseat-development-clusters", "-var", "environment=uxbridge", "-var-file=/home/s.pook/git/dataseat-dsp-kubernetes/cluster/development/development.tfvars", "-compact-warnings"}
[INFO]  AWS Auth provider used: "EnvProvider"
[INFO]  backend/local: starting Plan operation
[INFO]  provider: configuring client automatic mTLS
[INFO]  provider.terraform-provider-aws_v4.28.0_x5: configuring server automatic mTLS: timestamp=2022-10-07T15:53:13.332+0200
[INFO]  provider: configuring client automatic mTLS
[INFO]  provider.terraform-provider-null_v3.1.1_x5: configuring server automatic mTLS: timestamp=2022-10-07T15:53:13.657+0200
[WARN]  unexpected data: registry.terraform.io/hashicorp/null:stderr="{"@caller":"github.com/hashicorp/terraform-plugin-sdk/v2@v2.11.0/internal/logging/helper_schema.go:21","@level":"trace","@message":"Getting provider schema","@module":"sdk.helper_schema","@timestamp":"2022-10-07T15:53:13.776082+02:00"}"
[WARN]  unexpected data: registry.terraform.io/hashicorp/null:stderr="{"@caller":"github.com/hashicorp/terraform-plugin-sdk/v2@v2.11.0/internal/logging/helper_schema.go:21","@level":"trace","@message":"Found resource type","@module":"sdk.helper_schema","@timestamp":"2022-10-07T15:53:13.776130+02:00","tf_resource_type":"null_resource"}"
[WARN]  unexpected data: registry.terraform.io/hashicorp/null:stderr="{"@caller":"github.com/hashicorp/terraform-plugin-sdk/v2@v2.11.0/internal/logging/helper_schema.go:21","@level":"trace","@message":"Found data source type","@module":"sdk.helper_schema","@timestamp":"2022-10-07T15:53:13.776172+02:00","tf_data_source_type":"null_data_source"}"
[INFO]  provider: configuring client automatic mTLS
[INFO]  provider.terraform-provider-template_v2.2.0_x4: configuring server automatic mTLS: timestamp=2022-10-07T15:53:13.793+0200
[INFO]  provider: configuring client automatic mTLS
[INFO]  provider.terraform-provider-template_v2.2.0_x4: configuring server automatic mTLS: timestamp=2022-10-07T15:53:14.260+0200
[INFO]  provider: configuring client automatic mTLS
[INFO]  provider.terraform-provider-null_v3.1.1_x5: configuring server automatic mTLS: timestamp=2022-10-07T15:53:14.360+0200
[INFO]  provider: configuring client automatic mTLS
[INFO]  provider.terraform-provider-aws_v4.28.0_x5: configuring server automatic mTLS: timestamp=2022-10-07T15:53:14.604+0200
[INFO]  provider: configuring client automatic mTLS
[INFO]  provider.terraform-provider-aws_v4.28.0_x5: configuring server automatic mTLS: timestamp=2022-10-07T15:53:14.789+0200
[INFO]  provider: configuring client automatic mTLS
[INFO]  provider.terraform-provider-aws_v4.28.0_x5: configuring server automatic mTLS: timestamp=2022-10-07T15:53:15.023+0200
[INFO]  provider: configuring client automatic mTLS
[INFO]  provider.terraform-provider-aws_v4.28.0_x5: configuring server automatic mTLS: timestamp=2022-10-07T15:53:15.242+0200
[INFO]  provider: configuring client automatic mTLS
[INFO]  provider.terraform-provider-aws_v4.28.0_x5: configuring server automatic mTLS: timestamp=2022-10-07T15:53:15.493+0200
[INFO]  provider: configuring client automatic mTLS
[INFO]  provider.terraform-provider-aws_v4.28.0_x5: configuring server automatic mTLS: timestamp=2022-10-07T15:53:15.716+0200
[WARN]  unexpected data: registry.terraform.io/hashicorp/null:stderr="{"@caller":"github.com/hashicorp/terraform-plugin-sdk/v2@v2.11.0/internal/logging/helper_schema.go:21","@level":"trace","@message":"Getting provider schema","@module":"sdk.helper_schema","@timestamp":"2022-10-07T15:53:16.027071+02:00"}"
[WARN]  unexpected data: registry.terraform.io/hashicorp/null:stderr="{"@caller":"github.com/hashicorp/terraform-plugin-sdk/v2@v2.11.0/internal/logging/helper_schema.go:21","@level":"trace","@message":"Found resource type","@module":"sdk.helper_schema","@timestamp":"2022-10-07T15:53:16.027149+02:00","tf_resource_type":"null_resource"}
orp/terraform-plugin-sdk/v2@v2.11.0/internal/logging/helper_schema.go:21","@level":"trace","@message":"Found data source type","@module":"sdk.helper_schema","@timestamp":"2022-10-07T15:53:16.027222+02:00","tf_data_source_type":"null_data_source"}"
[WARN]  unexpected data: registry.terraform.io/hashicorp/null:stderr="{"@caller":"github.com/hashicorp/terraform-plugin-sdk/v2@v2.11.0/internal/logging/helper_schema.go:21","@level":"trace","@message":"Calling downstream","@module":"sdk.helper_schema","@timestamp":"2022-10-07T15:53:16.029499+02:00"}"
[WARN]  unexpected data: registry.terraform.io/hashicorp/null:stderr="{"@caller":"github.com/hashicorp/terraform-plugin-sdk/v2@v2.11.0/internal/logging/helper_schema.go:21","@level":"trace","@message":"Called downstream","@module":"sdk.helper_schema","@timestamp":"2022-10-07T15:53:16.029609+02:00"}"
[WARN]  unexpected data: registry.terraform.io/hashicorp/null:stderr="{"@caller":"github.com/hashicorp/terraform-plugin-sdk/v2@v2.11.0/internal/logging/helper_schema.go:21","@level":"trace","@message":"Calling downstream","@module":"sdk.helper_schema","@timestamp":"2022-10-07T15:53:16.030587+02:00"}"
[WARN]  unexpected data: registry.terraform.io/hashicorp/null:stderr="{"@caller":"github.com/hashicorp/terraform-plugin-sdk/v2@v2.11.0/internal/logging/helper_schema.go:21","@level":"trace","@message":"Called downstream","@module":"sdk.helper_schema","@timestamp":"2022-10-07T15:53:16.030672+02:00"}"
[WARN]  unexpected data: registry.terraform.io/hashicorp/null:stderr="{"@caller":"github.com/hashicorp/terraform-plugin-sdk/v2@v2.11.0/internal/logging/helper_schema.go:21","@level":"trace","@message":"Calling downstream","@module":"sdk.helper_schema","@timestamp":"2022-10-07T15:53:16.031795+02:00"}
orp/terraform-plugin-sdk/v2@v2.11.0/internal/logging/helper_schema.go:21","@level":"trace","@message":"Called downstream","@module":"sdk.helper_schema","@timestamp":"2022-10-07T15:53:16.031856+02:00"}"
[WARN]  unexpected data: registry.terraform.io/hashicorp/null:stderr="{"@caller":"github.com/hashicorp/terraform-plugin-sdk/v2@v2.11.0/internal/logging/helper_schema.go:21","@level":"trace","@message":"Calling downstream","@module":"sdk.helper_schema","@timestamp":"2022-10-07T15:53:16.032395+02:00"}"
[WARN]  unexpected data: registry.terraform.io/hashicorp/null:stderr="{"@caller":"github.com/hashicorp/terraform-plugin-sdk/v2@v2.11.0/internal/logging/helper_schema.go:21","@level":"trace","@message":"Called downstream","@module":"sdk.helper_schema","@timestamp":"2022-10-07T15:53:16.032467+02:00"}"
[WARN]  unexpected data: registry.terraform.io/hashicorp/null:stderr="{"@caller":"github.com/hashicorp/terraform-plugin-sdk/v2@v2.11.0/internal/logging/helper_schema.go:21","@level":"trace","@message":"Calling downstream","@module":"sdk.helper_schema","@timestamp":"2022-10-07T15:53:16.048458+02:00"}"
[WARN]  unexpected data: registry.terraform.io/hashicorp/null:stderr="{"@caller":"github.com/hashicorp/terraform-plugin-sdk/v2@v2.11.0/internal/logging/helper_schema.go:21","@level":"trace","@message":"Called downstream","@module":"sdk.helper_schema","@timestamp":"2022-10-07T15:53:16.048541+02:00"}"
[WARN]  provider.terraform-provider-aws_v4.28.0_x5: Response contains warning diagnostic: tf_provider_addr=registry.terraform.io/hashicorp/aws tf_req_id=a1c377a8-4a7c-1f62-3c17-87cabc719c5a tf_resource_type=aws_autoscaling_group @module=sdk.proto diagnostic_attribute=AttributeName("tags") diagnostic_detail="Use tag instead" diagnostic_severity=WARNING tf_proto_version=5.3 @caller=github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov5/internal/diag/diagnostics.go:57 diagnostic_summary="Argument is deprecated" tf_rpc=ValidateResourceTypeConfig timestamp=2022-10-07T15:53:16.084+0200
[WARN]  provider.terraform-provider-aws_v4.28.0_x5: Response contains warning diagnostic: tf_proto_version=5.3 tf_resource_type=aws_autoscaling_group @module=sdk.proto tf_req_id=a8d9237a-6686-140a-ea75-7b0fecf19f22 diagnostic_attribute=AttributeName("tags") diagnostic_detail="Use tag instead" tf_provider_addr=registry.terraform.io/hashicorp/aws @caller=github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov5/internal/diag/diagnostics.go:57 diagnostic_summary="Argument is deprecated" tf_rpc=ValidateResourceTypeConfig diagnostic_severity=WARNING timestamp=2022-10-07T15:53:16.086+0200
[WARN]  provider.terraform-provider-aws_v4.28.0_x5: Response contains warning diagnostic: tf_resource_type=aws_autoscaling_group @module=sdk.proto tf_proto_version=5.3 tf_req_id=3cf3ae3a-7051-096c-e299-450cc238a0bb diagnostic_summary="Argument is deprecated" tf_provider_addr=registry.terraform.io/hashicorp/aws diagnostic_detail="Use tag instead" diagnostic_severity=WARNING tf_rpc=ValidateResourceTypeConfig @caller=github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov5/internal/diag/diagnostics.go:57 diagnostic_attribute=AttributeName("tags") timestamp=2022-10-07T15:53:16.284+0200
[WARN]  provider.terraform-provider-aws_v4.28.0_x5: Response contains warning diagnostic: tf_resource_type=aws_autoscaling_group diagnostic_detail="Use tag instead" tf_provider_addr=registry.terraform.io/hashicorp/aws tf_req_id=817fd4ef-be4d-3b26-7f91-60c14c621ab4 @caller=github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov5/internal/diag/diagnostics.go:57 diagnostic_summary="Argument is deprecated" tf_proto_version=5.3 tf_rpc=ValidateResourceTypeConfig @module=sdk.proto diagnostic_attribute=AttributeName("tags") diagnostic_severity=WARNING timestamp=2022-10-07T15:53:16.308+0200
[WARN]  provider.terraform-provider-aws_v4.28.0_x5: Response contains warning diagnostic: tf_proto_version=5.3 diagnostic_attribute=AttributeName("tags") diagnostic_detail="Use tag instead" diagnostic_severity=WARNING diagnostic_summary="Argument is deprecated" tf_req_id=2c238e5f-adce-5fb0-c278-5e1c5f40cb61 @caller=github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov5/internal/diag/diagnostics.go:57 tf_resource_type=aws_autoscaling_group tf_provider_addr=registry.terraform.io/hashicorp/aws tf_rpc=ValidateResourceTypeConfig @module=sdk.proto timestamp=2022-10-07T15:53:16.364+0200
[INFO]  backend/local: plan calling Plan
[INFO]  provider: configuring client automatic mTLS
`

@jbardin
Copy link
Member

jbardin commented Oct 10, 2022

Hi @stuart12,

Thanks for filing the issue. In order to confirm the behavior, it would help to have the exact variable declaration you are using which crashed, along with the complete value you are assigning to the variable. A complete example should be achievable by adding a similarly structured value as the variable's default value.

Thanks!

@jbardin jbardin added waiting-response An issue/pull request is waiting for a response from the community waiting for reproduction unable to reproduce issue without further information and removed new new issue not yet triaged labels Oct 10, 2022
@stuart12
Copy link
Author

hi! I am sorry but I no longer know how to reproduce this bug. My changes to other parts of the code mean that terraform no longer crashes.

@jbardin
Copy link
Member

jbardin commented Oct 11, 2022

Thanks @stuart12. There may be a patch in an upcoming release which may address the issue. If not we can wait for a new issue to be filed.

Thanks

@jbardin jbardin closed this as not planned Won't fix, can't repro, duplicate, stale Oct 11, 2022
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug waiting for reproduction unable to reproduce issue without further information waiting-response An issue/pull request is waiting for a response from the community
Projects
None yet
Development

No branches or pull requests

2 participants