Closed mkielar closed 3 years ago
Hi @mkielar, thanks for reporting this! I was able to reproduce with your config on versions of Terraform from 0.12.29 to 0.14.0-rc1.
The randomness of the error message moving around makes me suspect that there's something related to map iteration in the diagnostic presentation, but I'd have to investigate further to be sure.
I believe the issue is in go-cty's convert.mismatchMessageObjects
function, which is attempting to find conversions from each of the given attribute types to the wanted attribute types. It does so by calling GetConversion
and diagnosing an error if the result is nil
, but I think it should first be checking that the two types are not equal.
There's an upstream PR which fixes this here: https://github.com/zclconf/go-cty/pull/78
Just noting that I saw this as well (also on 0.13.5
). In my case it was an object which expected foo = list(string)
, but I had mistakingly provided foo = string
, and it was giving me errors about other properties in the object instead.
Faced same issue with randomly spawned error about wrong attribute type with object. Tested on 0.13.5, 0.13.4 and 0.13.0 and even 0.14.0 :(
As I noted above, this bug is fixed upstream, and we expect the upstream library version to be released shortly. We'll have the fix rolled out with Terraform 0.14.1. Thanks for your patience!
thank you @alisdair . For me, it's just weird that no one reported that for previous versions...
I have Terraform version v0.14.4
and I have this same error.
My OS is: Linux Mint 20 64bit
.
When executing terraform plan
on top of the example available on the site https://registry.terraform.io/modules/terraform-aws-modules/rds/aws/latest/examples/complete-postgres I get the following output
2021/01/07 17:36:12 [WARN] Log levels other than TRACE are currently unreliable, and are supported only for backward compatibility.
Use TF_LOG=TRACE to see Terraform's internal logs.
2021/01/07 17:36:12 [INFO] Terraform version: 0.14.4
2021/01/07 17:36:12 [INFO] Go runtime version: go1.15.6
2021/01/07 17:36:12 [INFO] CLI args: []string{"/usr/bin/terraform", "plan"}
2021/01/07 17:36:12 [INFO] CLI command args: []string{"plan"}
2021/01/07 17:36:12 [WARN] Log levels other than TRACE are currently unreliable, and are supported only for backward compatibility.
Use TF_LOG=TRACE to see Terraform's internal logs.
2021/01/07 17:36:13 [INFO] Failed to read plugin lock file .terraform/plugins/linux_amd64/lock.json: open .terraform/plugins/linux_amd64/lock.json: no such file or directory
2021/01/07 17:36:13 [INFO] backend/local: starting Plan operation
2021-01-07T17:36:13.111-0300 [INFO] plugin: configuring client automatic mTLS
2021-01-07T17:36:13.158-0300 [INFO] plugin.terraform-provider-aws_v3.22.0_x5: configuring server automatic mTLS: timestamp=2021-01-07T17:36:13.158-0300
2021-01-07T17:36:13.294-0300 [WARN] plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2021/01/07 17:36:13 [INFO] terraform: building graph: GraphTypeValidate
2021-01-07T17:36:13.343-0300 [INFO] plugin: configuring client automatic mTLS
2021-01-07T17:36:13.393-0300 [INFO] plugin.terraform-provider-aws_v3.22.0_x5: configuring server automatic mTLS: timestamp=2021-01-07T17:36:13.393-0300
**2021-01-07T17:36:13.588-0300 [WARN] plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"**
2021/01/07 17:36:13 [INFO] backend/local: plan calling Plan
2021/01/07 17:36:13 [INFO] terraform: building graph: GraphTypePlan
2021-01-07T17:36:13.635-0300 [INFO] plugin: configuring client automatic mTLS
2021-01-07T17:36:13.682-0300 [INFO] plugin.terraform-provider-aws_v3.22.0_x5: configuring server automatic mTLS: timestamp=2021-01-07T17:36:13.682-0300
This line is a problem?
2021/01/07 17:36:13 [INFO] Failed to read plugin lock file .terraform/plugins/linux_amd64/lock.json: open .terraform/plugins/linux_amd64/lock.json: no such file or directory
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.
Terraform Version
Terraform Configuration Files
variables.tf
:variables-general.auto.tfvars
:Debug Output
Output is random.
Sometimes, I get this (correct error message):
Sometimes I get this (incorrect error message):
Crash Output
N/A
Expected Behavior
The error message should consistently be:
Actual Behavior
The error message is pretty random. In real scenario I had around 20 different attributes like
foo
andbar
in the example, and I the errors I was getting were pointing to different attribute on that level quite randomly, sometimes pointing that two attributes on the root level are missing. I have also never observed a correct error message in real use-case, only creating this SSCCE allowed me to - sometimes - see the correct error message.Steps to Reproduce
Each of the below fails
terraform plan
terraform console
tflint
version0.20.3
also returned random errors, from which I suspect the bug is in some kind of a shared library between the two.Additional Context
This issue makes it quite hard to spot what's actually wrong, especially that with large structures (as mentioned, I had more that 20 other attributes in the
config
structure) the correct error message is very rarely displayed (I never got the correct message it in around 50 tries). I've just spent over an hour tracking a silly typo. I'd say it's quite important thing to fix in bothterraform
andtflint
.References