nodejs icon indicating copy to clipboard operation
nodejs copied to clipboard

[sync-actions] Type FieldDefinition change from required false to true failed

Open lojzatran opened this issue 3 years ago • 2 comments

Description

When I have a fieldDefintion changed from required=false to required=true

{
  "name": {
    "en": "Subscription order"
  },
  "description": {
    "en": "Subscription order definition"
  },
  "resourceTypeIds": ["order"],
  "fieldDefinitions": [
    {
      "name": "deliveryDate",
      "type": {
        "name": "DateTime"
      },
      "required": true,   // changed here from false to true
      "label": {
        "en": "deliveryDate"
      },
      "inputHint": "SingleLine"
    }
  ]
}

sync-actions throws an error "Cannot read properties of undefined (reading 'values') and fails at this line: https://github.com/commercetools/nodejs/blob/4974bb700aa9469282f38da4e40ecbb8bba7d513/packages/sync-actions/src/types-actions.js#L131 When I inspect that code, diffValue has this value:

diffValue = `{
  "required": [
    false,
    true
  ]
}

Expected Behavior

Since there is no update action for this change I would expect following:

  1. It would try to remove the fieldDefinition and re-add it with the correct required value. This might not work since there could be resources created based on this type.
  2. If the previous point doesn't work, it should fail with a nice error describing what is the problem and what could be done.

lojzatran avatar Feb 18 '22 10:02 lojzatran

Hi team, any changes here? Thank you.

lojzatran avatar Sep 14 '22 19:09 lojzatran

I am getting this as well, would be great if it could be fixed

christina-grannas avatar Oct 17 '22 10:10 christina-grannas