opentofu / opentofu

OpenTofu lets you declaratively manage your cloud infrastructure.
https://opentofu.org
Mozilla Public License 2.0
23.34k stars 898 forks source link

Mock_data/Override_data Type Validation Error #2200

Open miles-qarik opened 13 hours ago

miles-qarik commented 13 hours ago

OpenTofu Version

v1.8.2
v1.8.5
v1.9.0-alpha2

OpenTofu Configuration Files

Bare minimum info needed to replicate issue

variable "false" {
  default = false
}

data "google_compute_networks" "all_networks" {
  project  = "my-networks-project"
}

This is my tftest.hcl file

mock_provider "google" {}

override_data {
    target = data.google_compute_networks.all_networks
    values = {
        networks = ["this-network", "that-network", "deez-networks"]
    }
}
run "demo" {
  assert {
    condition     = var.false == true
    error_message = "Debugging peer_networks: ${jsonencode(data.google_compute_networks.all_networks)}"
  }
}

Debug Output

https://gist.github.com/miles-qarik/ecd2fba9327cdaeb1ccac48f0406c78d

Expected Behavior

Networks value should have been updated and output correctly as it is receiving a valid list of strings

Actual Behavior

│ Warning: Ignored mock/override field `networks`
│ 
│   with data.google_compute_networks.all_networks,
│   on main.tf line 5, in data "google_compute_networks" "all_networks":
│    5: data "google_compute_networks" "all_networks" {
│ 
│ Values provided for override / mock must match resource fields types: list of string required, but received tuple.

Steps to Reproduce

  1. tofu init
  2. tofu test

Additional Context

No response

References

Similar behavior in #2140, #2139, #2038

cam72cam commented 13 hours ago

Just tried your example on main, looks like the work @ollevche did in the linked issues resolved it. I'll ping him to close this when they put out the patch release (tomorrow potentially).

ollevche commented 22 minutes ago

Yep, this is same root cause as in the linked issues so the fix will be released soon.