Skip to content

deep merge fails if the 2nd map is empty #471

@jgournet

Description

@jgournet

Describe the Bug

Using this simple setup:

data1.yaml:
---
test:
  my_list:
     - item1
     - item2


data2.yaml:
---
test:
  my_list:
     #- item1
     #- item3
     #- item4


data-source.tf:
locals {
  yaml_data_1 = file("${path.module}/data1.yaml")
  yaml_data_2 = file("${path.module}/data2.yaml")
}

data "utils_deep_merge_yaml" "example" {
  input = [
    local.yaml_data_1,
    local.yaml_data_2
  ]
  deep_copy_list = true
  append_list = true
}

versions.tf:
terraform {
  required_providers {
    utils = {
      source = "cloudposse/utils"
      # For local development,
      # install the provider on local computer by running `make install` from the root of the repo,
      # and uncomment the version below
      #version = "1.22"
    }
  }
}

Result:

Changes to Outputs:
  + deep_merge_output = {
      + test = {
          + my_list = null
        }
    }

Note: I tried with version 1.29 and 1.22, both yields the same
(but 1.22 works better when the map item is not empty)

Expected Behavior

Changes to Outputs:
  + deep_merge_output = {
      + test = {
          + my_list = [
              + "item1",
              + "item2",
            ]
        }
    }

Steps to Reproduce

See above

Screenshots

No response

Environment

  • OS: linux
  • deep merge versions: 1.29 and 1.22 (and probably all ?)
  • tf version: v1.11.4

Additional Context

No response

Metadata

Metadata

Assignees

Labels

bug🐛 An issue with the systemtriageNeeds triage

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions