如何修复AWS Step Functions中的”States.ReferencePathConflict”错误?

huangapple go评论75阅读模式
英文:

How to fix the "States.ReferencePathConflict" error in AWS Step Functions?

问题

以下是您要翻译的内容:

"我正在尝试在AWS中创建一个步骤函数,该函数迭代遍历交易列表,检查是否存在个人标签,如果交易状态码为200且存在个人标签,就进入SuccessState,如果失败,则将每个交易保存到Postgres表中。但是,我遇到了“States.ReferencePathConflict”错误,无法继续。

在TestPersonalClassifier中的输入:

{
"statusCode": 200,
"body": {
"transactions": [
{
"customer_id": "****5135",
"this_party_account_number": "****0600",
"source_transaction_category": "DEBIT",
"mcc": "0000",
"transaction_amount": -20,
"other_party_account_number": "****3214",
"other_party_name": "bank life"
},
{
"customer_id": "****5136",
"this_party_account_number": "****7900",
"source_transaction_category": "DEBIT",
"mcc": "0000",
"transaction_amount": -17.5,
"other_party_account_number": "****9567",
"other_party_name": "mt roskill liquor ce"
}
]
}
}

而且,通过TestPersonalClassifier Lambda函数,我得到了正确的输出:

{
"statusCode": 200,
"body": {
"transactions": [
{
"customer_id": "****5135",
"this_party_account_number": "************6600",
"source_transaction_category": "DEBIT",
"mcc": "0000",
"transaction_amount": -20,
"other_party_account_number": "*************4214",
"other_party_name": "bank life",
"personal_label": [
{
"label": "Insurance",
"confidence": 1.0
}
]
},
{
"customer_id": "****5136",
"this_party_account_number": "************7900",
"source_transaction_category": "DEBIT",
"mcc": "0000",
"transaction_amount": -17.5,
"other_party_account_number": "*************9567",
"other_party_name": "mt roskill liquor ce",
"personal_label": [
{
"label": "Entertainment",
"confidence": 1.0
}
]
}
]
}
}

我所需要的只是:如果在Lambda测试PersonalClassifier输出中statusCode= 200且personal_label存在,则进入SuccessState,否则失败。

当我运行这个步骤函数时,我收到以下错误:

States.ReferencePathConflict

无法应用步骤“testPersonalClassifierOutput”到输入中:

{
"statusCode": 200,
"body": {
"transactions": [
{
"customer_id": "****5135",
"this_party_account_number": "************6600",
"source_transaction_category": "DEBIT",
"mcc": "0000",
"transaction_amount": -20,
"other_party_account_number": "*************4214",
"other_party_name": "bank life",
"personal_label": [
{
"label": "Insurance",
"confidence": 1.0
}
]
},
{
"customer_id": "****5136",
"this_party_account_number": "************7900",
"source_transaction_category": "DEBIT",
"mcc": "0000",
"transaction_amount": -17.5,
"other_party_account_number": "*************9567",
"other_party_name": "mt roskill liquor ce",
"personal_label": [
{
"label": "Entertainment",
"confidence": 1.0
}
]
}
]
}
}

以下是步骤函数:

{
"Comment": "遍历每个交易块并检查是否存在个人标签",
"StartAt": "TestPersonalClassifier",
"States": {
"TestPersonalClassifier": {
"Type": "Task",
"Resource": "arn:aws:lambda:*:function:testPersonalClassifier",
"Next": "CheckPersonalLabelExistence"
},
"CheckPersonalLabelExistence": {
"Type": "Map",
"ItemsPath": "$.testPersonalClassifierOutput.body.transactions",
"Iterator": {
"StartAt": "CheckSingleTransactionPersonalLabel",
"States": {
"CheckSingleTransactionPersonalLabel": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.personal_label",
"IsPresent": true,
"Next": "SuccessState"
}
],
"Default": "PostgresWithNoLabels"
},
"PostgresWithNoLabels": {
"Type": "Task",
"Resource": "arn:aws:lambda:
:function:testSaveNoLabelAtPostgresDB",
"ResultPath": "$.postgresOutput",
"End": true
},
"SuccessState": {
"Type": "Pass",
"End": true
}
}
},
"Next": "Done"
},
"Done": {
"Type": "Succeed"
}
}
}

英文:

I am trying to create a Step Function in AWS that iterates through a list of transactions, checks for the presence of a personal label, if transactions has 200 status code and a personal_label exists go to SuccessState, if FailState save each single transactions at postgres table
However, I am running into a "States.ReferencePathConflict" error and cannot proceed.

Input at TestPersonalClassifier

  {
  "statusCode": 200,
  "body": {
    "transactions": [
      {
        "customer_id": "****5135",
        "this_party_account_number": "****0600",
        "source_transaction_category": "DEBIT",
        "mcc": "0000",
        "transaction_amount": -20,
        "other_party_account_number": "****3214",
        "other_party_name": "bank life"
      },
      {
        "customer_id": "****5136",
        "this_party_account_number": "****7900",
        "source_transaction_category": "DEBIT",
        "mcc": "0000",
        "transaction_amount": -17.5,
        "other_party_account_number": "****9567",
        "other_party_name": "mt roskill liquor ce"
      }
    ]
  }
}

and I'm getting the correct output via TestPersonalClassifier lamda too which is

 {"statusCode": 200,
  "body": {
    "transactions": [
      {
        "customer_id": "****5135",
        "this_party_account_number": "************6600",
        "source_transaction_category": "DEBIT",
        "mcc": "0000",
        "transaction_amount": -20,
        "other_party_account_number": "*************4214",
        "other_party_name": "bank life",
        "personal_label": [
          {
            "label": "Insurance",
            "confidence": 1.0
          }
        ]
      },
      {
        "customer_id": "****5136",
        "this_party_account_number": "************7900",
        "source_transaction_category": "DEBIT",
        "mcc": "0000",
        "transaction_amount": -17.5,
        "other_party_account_number": "*************9567",
        "other_party_name": "mt roskill liquor ce",
        "personal_label": [
          {
            "label": "Entertainment",
            "confidence": 1.0
          }
        ]
      }
    ]
  }
}

What I need is simply if at lambda testPersonalClassifier output has statusCode= 200 and personal_label exits go to SuccessState else fail

When I run this Step Function, I get the following error:

States.ReferencePathConflict

    Unable to apply step "testPersonalClassifierOutput" to input 
   {"statusCode": 200,
  "body": {
    "transactions": [
      {
        "customer_id": "****5135",
        "this_party_account_number": "************6600",
        "source_transaction_category": "DEBIT",
        "mcc": "0000",
        "transaction_amount": -20,
        "other_party_account_number": "*************4214",
        "other_party_name": "bank life",
        "personal_label": [
          {
            "label": "Insurance",
            "confidence": 1.0
          }
        ]
      },
      {
        "customer_id": "****5136",
        "this_party_account_number": "************7900",
        "source_transaction_category": "DEBIT",
        "mcc": "0000",
        "transaction_amount": -17.5,
        "other_party_account_number": "*************9567",
        "other_party_name": "mt roskill liquor ce",
        "personal_label": [
          {
            "label": "Entertainment",
            "confidence": 1.0
          }
        ]
      }
    ]
  }
}

here is the Step Function

{
  "Comment": "Iterate through each transaction block and check if personal label exists",
  "StartAt": "TestPersonalClassifier",
  "States": {
    "TestPersonalClassifier": {
      "Type": "Task",
      "Resource": "arn:aws:lambda:**********:function:testPersonalClassifier",
      "Next": "CheckPersonalLabelExistence"
    },
    "CheckPersonalLabelExistence": {
      "Type": "Map",
      "ItemsPath": "$.testPersonalClassifierOutput.body.transactions",
      "Iterator": {
        "StartAt": "CheckSingleTransactionPersonalLabel",
        "States": {
          "CheckSingleTransactionPersonalLabel": {
            "Type": "Choice",
            "Choices": [
              {
                "Variable": "$.personal_label",
                "IsPresent": true,
                "Next": "SuccessState"
              }
            ],
            "Default": "PostgresWithNoLabels"
          },
          "PostgresWithNoLabels": {
            "Type": "Task",
            "Resource": "arn:aws:lambda:*********:function:testSaveNoLabelAtPostgresDB",
            "ResultPath": "$.postgresOutput",
            "End": true
          },
          "SuccessState": {
            "Type": "Pass",
            "End": true
          }
        }
      },
      "Next": "Done"
    },
    "Done": {
      "Type": "Succeed"
    }
  }
}

答案1

得分: 0

你的ItemsPath似乎是不正确的。你指定了$.testPersonalClassifierOutput.body.transactions,但在你的Lambda函数的输出中并不存在这个路径。你需要将它更改为$.body.transactions

英文:

It appears that your ItemsPath is incorrect. You specified $.testPersonalClassifierOutput.body.transactions but that does not exist in the output from your Lambda function. You need to change it to $.body.transactions.

huangapple
  • 本文由 发表于 2023年3月7日 09:54:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/75657393.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定