commercetools / nodejs

Everything related to the Node.js ecosystem for the commercetools platform.
https://commercetools.github.io/nodejs/
MIT License
75 stars 70 forks source link

[sync-actions] State setTransitions update do not work correctly #1765

Open lojzatran opened 2 years ago

lojzatran commented 2 years ago

Description

When I have 2 arrays of transition in State resource:

[
  {
    "typeId": "state",
    "key": "Active"
  },
  {
    "typeId": "state",
    "key": "ReminderSent"
  },
  {
    "typeId": "state",
    "key": "Cancelled"
  },
  {
    "typeId": "state",
    "key": "Paused"
  },
  {
    "typeId": "state",
    "key": "Error"
  }
]
[
  {
    "typeId": "state",
    "key": "Cancelled"
  },
  {
    "typeId": "state",
    "key": "Paused"
  },
  {
    "typeId": "state",
    "key": "Error"
  },
  {
    "typeId": "state",
    "key": "Active"
  },
  {
    "typeId": "state",
    "key": "ReminderSent"
  }
]

This would generate an update action:

[
  {
    "action": "setTransitions",
    "transitions": [
      {
        "typeId": "state",
        "key": "Active"
      },
      {
        "typeId": "state",
        "key": "ReminderSent"
      },
      {
        "typeId": "state",
        "key": "Cancelled"
      },
      {
        "typeId": "state",
        "key": "Paused"
      },
      {
        "typeId": "state",
        "key": "Error"
      }
    ]
  }
]

However, this update action would fail with this error: "statusCode":400,"status":400,"message":"'transitions' has no changes.".

In this case, sync-actions should not generate any update actions, even if the elements in the transition array changed their positions.

lojzatran commented 2 years ago

Hi team, any changes here? Thank you.