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

update custom fields attributes in custom types - reference object custom attribute data wiped out #487

Closed
nxverma opened this issue May 3, 2024 · 1 comment
Labels
awaiting-response bug Something isn't working

Comments

@nxverma
Copy link

nxverma commented May 3, 2024

Hi Team,

We notice weird behaviour when we update custom fields attributes in custom types , all Entities (ex Business Unit) which referring this custom type as custom attributes loose all data / values for existing attributes . we have to again set values in Entity for custom attributes. It is very risky in production as we don't want existing custom attribute values wiped out when we do add/update attributes in referenced custom type.

When I checked with CT team , they said while applying any change in custom attribute in ref custom Type we need to pass all attributes in update request. Need to check in TF code if we update any CustomType , will TF code pass all attributes of custom types ???? or only updated attributes

@nxverma nxverma added bug Something isn't working triage Needs triage labels May 3, 2024
@demeyerthom demeyerthom removed the triage Needs triage label May 3, 2024
@demeyerthom
Copy link
Member

Hi @nxverma!

I am not sure I understand what is going on.

When a commercetools_type gets updated we parse the fields that have changed, and create updates based on these: https://docs.commercetools.com/api/projects/types#update-actions. So when adding the field bar to the below it will just create an update action to add bar, but change nothing else.

resource "commercetools_type" "my-custom-type" {
  ...
  field {
    name  = "foo"
    label = {
      en = "foo"
      nl = "foo"
    }
    type {
      name = "String"
    }
  }

  # This gets added
  field {
    name  = "bar"
    label = {
      en = "bar"
      nl = "bar"
    }
    type {
      name = "String"
    }
  }
}

Do you have an example where it is going wrong for you? I played around a bit with it, but any entities implementing this custom type do not lose the data in previously set custom fields

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-response bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants