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

element types must match for conversion to set error when using set of object with optional map with optional attribute. #36247

Closed
bellis-ai opened this issue Dec 27, 2024 · 3 comments · Fixed by #36262
Assignees
Labels
bug confirmed a Terraform Core team member has reproduced this issue cty Use in conjunction with "upstream" when cty is the relevant upstream upstream

Comments

@bellis-ai
Copy link

bellis-ai commented Dec 27, 2024

Terraform Version

Terraform v1.10.3
on linux_amd64

Terraform Configuration Files

variable "tenants" {
  type = set(
    object(
      {
        optional_map = optional(map( object({
            asdf = optional(string, "aaa")
        })), {})
      }
    )
  )
}

Debug Output

2024-12-27T07:39:25.066-0500 [INFO]  Terraform version: 1.10.3
2024-12-27T07:39:25.067-0500 [DEBUG] using github.com/hashicorp/go-tfe v1.70.0
2024-12-27T07:39:25.067-0500 [DEBUG] using github.com/hashicorp/hcl/v2 v2.23.0
2024-12-27T07:39:25.067-0500 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1
2024-12-27T07:39:25.067-0500 [DEBUG] using github.com/zclconf/go-cty v1.15.1-0.20241111215639-63279be090d7
2024-12-27T07:39:25.067-0500 [INFO]  Go runtime version: go1.23.3
2024-12-27T07:39:25.067-0500 [INFO]  CLI args: []string{"terraform", "plan"}
2024-12-27T07:39:25.067-0500 [TRACE] Stdout is a terminal of width 383
2024-12-27T07:39:25.067-0500 [TRACE] Stderr is a terminal of width 383
2024-12-27T07:39:25.067-0500 [TRACE] Stdin is a terminal
2024-12-27T07:39:25.067-0500 [DEBUG] Attempting to open CLI config file: /home/bellis/.terraformrc
2024-12-27T07:39:25.067-0500 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2024-12-27T07:39:25.067-0500 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2024-12-27T07:39:25.067-0500 [DEBUG] ignoring non-existing provider search directory /home/bellis/.terraform.d/plugins
2024-12-27T07:39:25.067-0500 [DEBUG] ignoring non-existing provider search directory /home/bellis/.local/share/terraform/plugins
2024-12-27T07:39:25.067-0500 [DEBUG] ignoring non-existing provider search directory /usr/local/share/terraform/plugins
2024-12-27T07:39:25.067-0500 [DEBUG] ignoring non-existing provider search directory /usr/share/terraform/plugins
2024-12-27T07:39:25.067-0500 [DEBUG] ignoring non-existing provider search directory /var/lib/snapd/desktop/terraform/plugins
2024-12-27T07:39:25.067-0500 [INFO]  CLI command args: []string{"plan"}
2024-12-27T07:39:25.067-0500 [TRACE] Meta.Backend: no config given or present on disk, so returning nil config
2024-12-27T07:39:25.067-0500 [TRACE] Meta.Backend: backend has not previously been initialized in this working directory
2024-12-27T07:39:25.067-0500 [TRACE] Meta.Backend: using default local state only (no backend configuration, and no existing initialized backend)
2024-12-27T07:39:25.067-0500 [TRACE] Meta.Backend: instantiated backend of type <nil>
2024-12-27T07:39:25.068-0500 [DEBUG] checking for provisioner in "."
2024-12-27T07:39:25.069-0500 [DEBUG] checking for provisioner in "/usr/bin"
2024-12-27T07:39:25.069-0500 [TRACE] Meta.Backend: backend <nil> does not support operations, so wrapping it in a local backend
2024-12-27T07:39:25.069-0500 [INFO]  backend/local: starting Plan operation
2024-12-27T07:39:25.069-0500 [TRACE] backend/local: requesting state manager for workspace "default"
2024-12-27T07:39:25.069-0500 [TRACE] backend/local: state manager for workspace "default" will:
 - read initial snapshot from terraform.tfstate
 - write new snapshots to terraform.tfstate
 - create any backup at terraform.tfstate.backup
2024-12-27T07:39:25.069-0500 [TRACE] backend/local: requesting state lock for workspace "default"
2024-12-27T07:39:25.069-0500 [TRACE] statemgr.Filesystem: preparing to manage state snapshots at terraform.tfstate
2024-12-27T07:39:25.069-0500 [TRACE] statemgr.Filesystem: no previously-stored snapshot exists
2024-12-27T07:39:25.069-0500 [TRACE] statemgr.Filesystem: locking terraform.tfstate using fcntl flock
2024-12-27T07:39:25.070-0500 [TRACE] statemgr.Filesystem: writing lock metadata to .terraform.tfstate.lock.info
2024-12-27T07:39:25.070-0500 [TRACE] backend/local: reading remote state for workspace "default"
2024-12-27T07:39:25.070-0500 [TRACE] statemgr.Filesystem: reading latest snapshot from terraform.tfstate
2024-12-27T07:39:25.070-0500 [TRACE] statemgr.Filesystem: snapshot file has nil snapshot, but that's okay
2024-12-27T07:39:25.070-0500 [TRACE] statemgr.Filesystem: read nil snapshot
2024-12-27T07:39:25.070-0500 [TRACE] backend/local: populating backendrun.LocalRun for current working directory
2024-12-27T07:39:25.070-0500 [TRACE] terraform.NewContext: starting
2024-12-27T07:39:25.070-0500 [TRACE] terraform.NewContext: complete
2024-12-27T07:39:25.070-0500 [TRACE] backend/local: requesting interactive input, if necessary
2024-12-27T07:39:25.070-0500 [TRACE] Context.Input: Prompting for provider arguments
2024-12-27T07:39:25.070-0500 [TRACE] backend/local: running validation operation
2024-12-27T07:39:25.070-0500 [DEBUG] Building and walking validate graph
2024-12-27T07:39:25.070-0500 [TRACE] building graph for walkValidate
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.ConfigTransformer
2024-12-27T07:39:25.070-0500 [TRACE] ConfigTransformer: Starting for path:
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.ConfigTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.RootVariableTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.RootVariableTransformer with new graph:
  var.tenants - *terraform.NodeRootVariable
  ------
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.ModuleVariableTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.ModuleVariableTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.variableValidationTransformer
2024-12-27T07:39:25.070-0500 [TRACE] variableValidationTransformer: adding validation nodes for any existing variable evaluation nodes
2024-12-27T07:39:25.070-0500 [TRACE] variableValidationTransformer: var.tenants has no validation rules
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.variableValidationTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.LocalTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.LocalTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.OutputTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.OutputTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.checkTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.checkTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.OrphanResourceInstanceTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.OrphanResourceInstanceTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.StateTransformer
2024-12-27T07:39:25.070-0500 [TRACE] StateTransformer: pointless no-op call, creating no nodes at all
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.StateTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.AttachStateTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.AttachStateTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.OrphanOutputTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.OrphanOutputTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.AttachResourceConfigTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.AttachResourceConfigTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.graphTransformerMulti
2024-12-27T07:39:25.070-0500 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.externalProviderTransformer
2024-12-27T07:39:25.070-0500 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.externalProviderTransformer with new graph:
  var.tenants - *terraform.NodeRootVariable
  ------
2024-12-27T07:39:25.070-0500 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.ProviderConfigTransformer
2024-12-27T07:39:25.070-0500 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.ProviderConfigTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.MissingProviderTransformer
2024-12-27T07:39:25.070-0500 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.MissingProviderTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.ProviderTransformer
2024-12-27T07:39:25.070-0500 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.ProviderTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.PruneProviderTransformer
2024-12-27T07:39:25.070-0500 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.PruneProviderTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.graphTransformerMulti (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.RemovedModuleTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.RemovedModuleTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.AttachSchemaTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.AttachSchemaTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.ModuleExpansionTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.ModuleExpansionTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.ExternalReferenceTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.ExternalReferenceTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.ReferenceTransformer
2024-12-27T07:39:25.070-0500 [DEBUG] ReferenceTransformer: "var.tenants" references: []
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.ReferenceTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.AttachDependenciesTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.AttachDependenciesTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.attachDataResourceDependsOnTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.attachDataResourceDependsOnTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.DestroyEdgeTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.DestroyEdgeTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.pruneUnusedNodesTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.pruneUnusedNodesTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.TargetsTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.TargetsTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.ForcedCBDTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.ForcedCBDTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.ephemeralResourceCloseTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.ephemeralResourceCloseTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.CloseProviderTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.CloseProviderTransformer (no changes)
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.CloseRootModuleTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.CloseRootModuleTransformer with new graph:
  root - *terraform.nodeCloseModule
    var.tenants - *terraform.NodeRootVariable
  var.tenants - *terraform.NodeRootVariable
  ------
2024-12-27T07:39:25.070-0500 [TRACE] Executing graph transform *terraform.TransitiveReductionTransformer
2024-12-27T07:39:25.070-0500 [TRACE] Completed graph transform *terraform.TransitiveReductionTransformer (no changes)
2024-12-27T07:39:25.070-0500 [DEBUG] Starting graph walk: walkValidate
2024-12-27T07:39:25.070-0500 [TRACE] vertex "var.tenants": starting visit (*terraform.NodeRootVariable)
2024-12-27T07:39:25.070-0500 [TRACE] vertex "var.tenants": belongs to
2024-12-27T07:39:25.070-0500 [TRACE] NodeRootVariable: evaluating var.tenants
2024-12-27T07:39:25.070-0500 [TRACE] prepareFinalInputVariableValue: preparing var.tenants
2024-12-27T07:39:25.070-0500 [TRACE] vertex "var.tenants": visit complete
2024-12-27T07:39:25.070-0500 [TRACE] vertex "root": starting visit (*terraform.nodeCloseModule)
2024-12-27T07:39:25.070-0500 [TRACE] vertex "root": does not belong to any module instance
2024-12-27T07:39:25.070-0500 [TRACE] vertex "root": visit complete
2024-12-27T07:39:25.070-0500 [INFO]  backend/local: plan calling Plan
2024-12-27T07:39:25.071-0500 [DEBUG] Building and walking plan graph for NormalMode
2024-12-27T07:39:25.071-0500 [TRACE] building graph for walkPlan
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.ConfigTransformer
2024-12-27T07:39:25.071-0500 [TRACE] ConfigTransformer: Starting for path:
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.ConfigTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.RootVariableTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.RootVariableTransformer with new graph:
  var.tenants - *terraform.NodeRootVariable
  ------
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.ModuleVariableTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.ModuleVariableTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.variableValidationTransformer
2024-12-27T07:39:25.071-0500 [TRACE] variableValidationTransformer: adding validation nodes for any existing variable evaluation nodes
2024-12-27T07:39:25.071-0500 [TRACE] variableValidationTransformer: var.tenants has no validation rules
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.variableValidationTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.LocalTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.LocalTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.OutputTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.OutputTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.checkTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.checkTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.OrphanResourceInstanceTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.OrphanResourceInstanceTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.StateTransformer
2024-12-27T07:39:25.071-0500 [TRACE] StateTransformer: creating nodes for deposed instance objects only
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.StateTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.AttachStateTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.AttachStateTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.OrphanOutputTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.OrphanOutputTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.AttachResourceConfigTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.AttachResourceConfigTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.graphTransformerMulti
2024-12-27T07:39:25.071-0500 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.externalProviderTransformer
2024-12-27T07:39:25.071-0500 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.externalProviderTransformer with new graph:
  var.tenants - *terraform.NodeRootVariable
  ------
2024-12-27T07:39:25.071-0500 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.ProviderConfigTransformer
2024-12-27T07:39:25.071-0500 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.ProviderConfigTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.MissingProviderTransformer
2024-12-27T07:39:25.071-0500 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.MissingProviderTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.ProviderTransformer
2024-12-27T07:39:25.071-0500 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.ProviderTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.PruneProviderTransformer
2024-12-27T07:39:25.071-0500 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.PruneProviderTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.graphTransformerMulti (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.RemovedModuleTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.RemovedModuleTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.AttachSchemaTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.AttachSchemaTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.ModuleExpansionTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.ModuleExpansionTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.ExternalReferenceTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.ExternalReferenceTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.ReferenceTransformer
2024-12-27T07:39:25.071-0500 [DEBUG] ReferenceTransformer: "var.tenants" references: []
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.ReferenceTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.AttachDependenciesTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.AttachDependenciesTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.attachDataResourceDependsOnTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.attachDataResourceDependsOnTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.DestroyEdgeTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.DestroyEdgeTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.pruneUnusedNodesTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.pruneUnusedNodesTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.TargetsTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.TargetsTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.ForcedCBDTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.ForcedCBDTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.ephemeralResourceCloseTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.ephemeralResourceCloseTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.CloseProviderTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.CloseProviderTransformer (no changes)
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.CloseRootModuleTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.CloseRootModuleTransformer with new graph:
  root - *terraform.nodeCloseModule
    var.tenants - *terraform.NodeRootVariable
  var.tenants - *terraform.NodeRootVariable
  ------
2024-12-27T07:39:25.071-0500 [TRACE] Executing graph transform *terraform.TransitiveReductionTransformer
2024-12-27T07:39:25.071-0500 [TRACE] Completed graph transform *terraform.TransitiveReductionTransformer (no changes)
2024-12-27T07:39:25.071-0500 [DEBUG] Starting graph walk: walkPlan
2024-12-27T07:39:25.071-0500 [TRACE] vertex "var.tenants": starting visit (*terraform.NodeRootVariable)
2024-12-27T07:39:25.071-0500 [TRACE] vertex "var.tenants": belongs to
2024-12-27T07:39:25.071-0500 [TRACE] NodeRootVariable: evaluating var.tenants
2024-12-27T07:39:25.071-0500 [TRACE] prepareFinalInputVariableValue: preparing var.tenants
2024-12-27T07:39:25.071-0500 [ERROR] prepareFinalInputVariableValue: var.tenants has unsuitable type
  got:  {{{} [{{{} map[optional_map:{{{} map[] map[]}}] map[]}} {{{} map[optional_map:{{{} {{{} map[asdf:{{{} %!s(cty.primitiveTypeKind=83)}}] map[]}}}}] map[]}}]}}
  want: {{{} {{{} map[optional_map:{{{} {{{} map[asdf:{{{} %!s(cty.primitiveTypeKind=83)}}] map[asdf:{}]}}}}] map[optional_map:{}]}}}}
2024-12-27T07:39:25.071-0500 [ERROR] vertex "var.tenants" error: Invalid value for input variable
2024-12-27T07:39:25.071-0500 [TRACE] vertex "var.tenants": visit complete, with errors
2024-12-27T07:39:25.071-0500 [TRACE] dag/walk: upstream of "root" errored, so skipping
2024-12-27T07:39:25.071-0500 [WARN]  Planning encountered errors, so plan is not applyable
2024-12-27T07:39:25.071-0500 [INFO]  backend/local: plan operation complete
Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: Invalid value for input variable
│ 
│   on terraform.tfvars line 1:
│    1: tenants = [
│    2:     {
│    3:         optional_map = {}
│    4:     },
│    5:     {
│    6:     }
│    7: ]
│ 
│ The given value is not suitable for var.tenants declared at main.tf:2,1-19: element types must all match for conversion to set.
╵
2024-12-27T07:39:25.071-0500 [TRACE] statemgr.Filesystem: removing lock metadata file .terraform.tfstate.lock.info
2024-12-27T07:39:25.071-0500 [TRACE] statemgr.Filesystem: unlocking terraform.tfstate using fcntl flock

Expected Behavior

No issues when generating plan

Actual Behavior

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: Invalid value for input variable
│ 
│   on terraform.tfvars line 1:
│    1: tenants = [
│    2:     {
│    3:         optional_map = {}
│    4:     },
│    5:     {
│    6:     }
│    7: ]
│ 
│ The given value is not suitable for var.tenants declared at main.tf:2,1-19: element types must all match for conversion to set.

Steps to Reproduce

  1. terraform plan

Additional Context

Here is the provided terraform.tfvars

tenants = [
    {
        optional_map = {}
    },
    {
    }
]

References

Related, but should have been fixed 2 years ago?
#31924

Generative AI / LLM assisted development?

no

@bellis-ai bellis-ai added bug new new issue not yet triaged labels Dec 27, 2024
@liamcervante liamcervante added confirmed a Terraform Core team member has reproduced this issue and removed new new issue not yet triaged labels Jan 2, 2025
@liamcervante liamcervante self-assigned this Jan 2, 2025
@liamcervante liamcervante added upstream cty Use in conjunction with "upstream" when cty is the relevant upstream labels Jan 2, 2025
@liamcervante
Copy link
Member

Hi @bellis-ai, thanks for filing this. I can replicate it so I've marked as confirmed.

This is a problem in our upstream type library go-cty. It seems we've previously fixed this for lists and sets, but maps were missed as the original reproduction didn't cause this problem in maps. This reproduction exposes the issue in maps, so we can roll out a fix for it.

@liamcervante
Copy link
Member

You can follow the potential fix to the library here: zclconf/go-cty#198.

@liamcervante
Copy link
Member

The fix has been merged upstream, we're waiting for the next version of the library to be released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug confirmed a Terraform Core team member has reproduced this issue cty Use in conjunction with "upstream" when cty is the relevant upstream upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants