VladRassokhin / intellij-hcl

HCL language support for IntelliJ platform based IDEs
Apache License 2.0
244 stars 47 forks source link

Variable value type warning on valid object #367

Open solarmosaic-kflorence opened 2 years ago

solarmosaic-kflorence commented 2 years ago

Prerequisites

Installation details

Terraform Configuration Files

variable "build" {
  default = {
    compile = {
      artifacts = [
        {
          base_directory = null
          discard_paths  = null
          files          = ["**/*"]
          name           = null
        }
      ]
      build_commands         = ["sbt -Dsbt.log.noformat=true +compile"]
      docker_support_enabled = false
      description            = "Compile the project."
      name                   = "ScalaDoc"
      input_artifacts        = ["source"]
      output_artifacts       = ["compiled"]
      run_order              = 1
    }
    compile-doc = {
      artifacts              = []
      build_commands         = ["sbt -Dsbt.log.noformat=true +compile:doc"]
      docker_support_enabled = false
      description            = "Generate documentation."
      name                   = "ScalaDoc"
      input_artifacts        = ["compiled"]
      output_artifacts       = []
      run_order              = 1
    }
  }
  description = "Configuration for the CodeBuild validation project which are executed during the 'Build' stage of the pipeline."
  type = map(object({
    artifacts = list(object({
      base_directory = string
      discard_paths  = string
      files          = list(string)
      name           = string
    }))
    build_commands         = list(string)
    docker_support_enabled = bool
    description            = string
    name                   = string
    input_artifacts        = list(string)
    output_artifacts       = list(string)
    run_order              = number
  }))
}

Exception

Variable value type 'object({compile=object({artifacts=list(object({base_directory=null, discard_paths=null, files=list(string), name=null})), build_commands=list(string), description=string, docker_support_enabled=bool, input_artifacts=list(string), name=string, output_artifacts=list(string), run_order=number}), compile-doc=object({artifacts=list, build_commands=list(string), description=string, docker_support_enabled=bool, input_artifacts=list(string), name=string, output_artifacts=list, run_order=number})})' doesn't match default value type 'map(object({artifacts=list(object({base_directory=string, discard_paths=string, files=list(string), name=string})), build_commands=list(string), docker_support_enabled=bool, description=string, name=string, input_artifacts=list(string), output_artifacts=list(string), run_order=number}))'

It seems from the warning message that the inner types of the list() is not taken into account unless it has a value. Perhaps similar to https://github.com/VladRassokhin/intellij-hcl/issues/362

Expected Behavior

There should be no warning, as the default value is correct.

Actual Behavior

A warning is displayed in the editor and the default object is highlighted.

Screen Shot 2021-12-15 at 4 40 36 PM

Steps to Reproduce

Paste the above Terraform configuration into a Terraform file (e.g. variables.tf). If I update the default object to the following, the warning goes away:

default = {
  compile = {
    artifacts = [
      {
        base_directory = null
        discard_paths  = null
        files          = ["**/*"]
        name           = null
      }
    ]
    build_commands         = ["sbt -Dsbt.log.noformat=true +compile"]
    docker_support_enabled = false
    description            = "Compile the project."
    name                   = "ScalaDoc"
    input_artifacts        = ["source"]
    output_artifacts       = ["compiled"]
    run_order              = 1
  }
  compile-doc = {
    artifacts = [
      {
        base_directory = null
        discard_paths  = null
        files          = ["**/*"]
        name           = null
      }
    ]
    build_commands         = ["sbt -Dsbt.log.noformat=true +compile:doc"]
    docker_support_enabled = false
    description            = "Generate documentation."
    name                   = "ScalaDoc"
    input_artifacts        = ["compiled"]
    output_artifacts       = ["output"]
    run_order              = 1
  }
}

Notice that artifacts and output_artifacts both now have values inside of the lists.