serverlessworkflow/sdk-go

For States that are used for Compensation Transition is optional but Validator throws an error

ilewin opened this issue · 0 comments

ilewin commented

What happened: Validation Error: Error: Field validation for 'Transition' failed on the 'required' tag.

{
  "id": "orderly",
  "name": "Orderly",
  "start": "First",
  "states": [
    {
      "name": "First",
      "type": "operation",
      "actions": [
        {
          "functionRef": {
            "refName": "Order",
            "arguments": {
              "input": {
                "train": "${.train}",
                "person": "${.order[0]}"
              }
            }
          },
          "actionDataFilter": {
            "results": "${ {train: .output} }"
          }
        }
      ],
      "transition": "Secend",
      "compensatedBy": "DeorderFirst"
    },
    {
      "name": "DeorderFirst",
      "type": "operation",
      "actions": [
        {
          "functionRef": {
            "refName": "DeOrder",
            "arguments": {
              "input": {
                "train": "${.train}",
                "person": "${.order[0]}"
              }
            }
          },
          "actionDataFilter": {
            "results": "${ {train: .output} }"
          }
        }
      ],
      "usedForCompensation": true
    },
    {
      "name": "PutJay",
      "type": "operation",
      "actions": [
        {
          "functionRef": {
            "refName": "Order",
            "arguments": {
              "input": {
                "train": "${.train}",
                "person": "jay"
              }
            }
          },
          "actionDataFilter": {
            "results": "${ {train: .output} }"
          }
        }
      ],
      "usedForCompensation": true
    },
    {
      "name": "Secend",
      "type": "operation",
      "actions": [
        {
          "functionRef": {
            "refName": "Order",
            "arguments": {
              "input": {
                "train": "${.train}",
                "person": "${.order[1]}"
              }
            }
          },
          "actionDataFilter": {
            "results": "${ {train: .output} }"
          }
        }
      ],
      "transition": "Third",
      "compensatedBy": "DeorderSecend"
    },
    {
      "name": "DeorderSecend",
      "type": "operation",
      "actions": [
        {
          "functionRef": {
            "refName": "DeOrder",
            "arguments": {
              "input": {
                "train": "${.train}",
                "person": "${.order[1]}"
              }
            }
          },
          "actionDataFilter": {
            "results": "${ {train: .output} }"
          }
        }
      ],
      "transition": "PutJay",
      "usedForCompensation": true
    },
    {
      "name": "Third",
      "type": "operation",
      "actions": [
        {
          "functionRef": {
            "refName": "Order",
            "arguments": {
              "input": {
                "train": "${.train}",
                "person": "${.order[2]}"
              }
            }
          },
          "actionDataFilter": {
            "results": "${ {train: .output} }"
          }
        }
      ],
      "transition": {
        "nextState": "Final",
        "compensate": true
      },
      "compensatedBy": "DeorderThird"
    },
    {
      "name": "DeorderThird",
      "type": "operation",
      "actions": [
        {
          "functionRef": {
            "refName": "DeOrder",
            "arguments": {
              "input": {
                "train": "${.train}",
                "person": "${.order[2]}"
              }
            }
          },
          "actionDataFilter": {
            "results": "${ {train: .output} }"
          }
        }
      ],
      "usedForCompensation": true
    },
    {
      "end": true,
      "name": "Final",
      "type": "operation",
      "actions": [
        {
          "functionRef": {
            "refName": "Order",
            "arguments": {
              "input": {
                "train": "${.train}",
                "person": "sudanshu"
              }
            }
          },
          "actionDataFilter": {
            "results": "${ {train: .output} }"
          }
        }
      ]
    }
  ],
  "retries": [
    {
      "name": "Default",
      "delay": "PT30S",
      "jitter": 0,
      "multiplier": 1.1,
      "maxAttempts": 50
    }
  ],
  "version": "1.0",
  "timeouts": {
    "actionExecTimeout": "PT15M"
  },
  "functions": [
    {
      "name": "Order",
      "operation": "cisco.testing.v1.0.0.load.Order"
    },
    {
      "name": "DeOrder",
      "operation": "cisco.testing.v1.0.0.load.DeOrder"
    }
  ],
  "description": "Order/Deorder",
  "specVersion": "1.8",
  "expressionLang": "jq"
}

What you expected to happen: The Definition above should not raise any errors

How to reproduce it: Unmarshal definition above

Anything else we need to know?:

Environment:

  • Specification version used:
  • Go version: