terraform-provider-commercetools icon indicating copy to clipboard operation
terraform-provider-commercetools copied to clipboard

Not able to set multiple values for a custom field type as Set of string while creating Shipping Method

Open rohit-singh-lll opened this issue 3 years ago • 1 comments

Information Terraform version: 1.2.5 Provider version: 1.4.1 Resource: commercetools_shipping_method

To Reproduce Steps to reproduce the behavior: I have a created a custom type on Shipping Method having a custom field as set of string. Then, I am trying to add multiple values for a custom field type as Set of string while creating Shipping Method but getting an error. Requesting you to please help me here.

ERROR - The value '"["A"]"' is not valid for field 'multipleValueAttributes'

# Terraform code
resource "commercetools_type" "shipping-method-type" {
  key = "ext-shipping-method"
  name = {
    en-US = "Shipping Method extension"
  }
  description = {
    en = "Shipping Method extension fields"
  }
  resource_type_ids = ["shipping-method"]
   field {
    name = "multipleValueAttributes"
    label = {
      en-US = "Multiple Value Attributes"
    }
    required = false
    type {
      name = "Set"
      element_type {
        name = "String"
      }
    }
  }
}

# Shipping Methods
resource "commercetools_shipping_method" "TestShippingMethod" {
  name = "Test Shipping Method"
  key = "testShippingMethod"
  is_default = true
  tax_category_id   = commercetools_tax_category.tax-category.id
  custom {
    type_id = commercetools_type.shipping-method-type.id
    fields = {
     # multipleValueAttributes = jsonencode(["A","B"])
      multipleValueAttributes = jsonencode(["A"])
    }
  }
}

rohit-singh-lll avatar Aug 30 '22 05:08 rohit-singh-lll

Slightly different use case, but same outcome for me. Trying to set a Reference type custom field, setting it as jsonencode({ typeId: "key-value-document", id: "some-uuid" }) and it doesn't work.

The error I get is very similar: The value '"{\"id\":\"some-id\",\"typeId\":\"key-value-document\"}"' is not valid for field 'myFieldName'.

alexbchr avatar Aug 30 '22 19:08 alexbchr

Thank you for reporting @rohit-singh-lll

It seems the problem with Set types is already fixed by @mvantellingen on the main branch.

@alexbchr

I was able to reproduce it for Reference types, going to send a fix for that one. Thank you!

onur9 avatar Sep 05 '22 11:09 onur9