DataDog / datadog-ci

Use Datadog from your CI.
https://datadoghq.com
Apache License 2.0
127 stars 54 forks source link

Skip sfn->Lambda context injection of Payload is not object (case 3) #1461

Closed lym953 closed 1 week ago

lym953 commented 1 week ago

What

In a State Machine, if a Lambda execution step's Payload field is not a JSON object, e.g.

    "Lambda Invoke": {
      "Type": "Task",
      "Resource": "arn:aws:states:::lambda:invoke",
      "OutputPath": "$.Payload",
      "Parameters": {
        "FunctionName": "arn:aws:lambda:sa-east-1:425362996713:function:yimingPlayground",
        "Payload": "Just a string!"
      },
      "Next": "Step Functions StartExecution"
    },

then print a warning and skip context injection.

This is case # 3 in this design doc: Fixing Step Function Instrumentation

Why

To inject context into Lambda payload, the payload must be a JSON dictionary. Injection can't work if payload is a string.

Testing

Automated testing

Passed the added test and existing tests

Manual testing

Steps
  1. Change the Lambda Execution step to have a string Payload field as shown in the "What" section
  2. Build the package: yarn prepack
  3. Instrument the Step Function using ./dist/cli.js stepfunctions instrument
Result

A warning is printed:

image

Review checklist

datadog-datadog-prod-us1[bot] commented 1 week ago

Datadog Report

Branch report: yiming.luo/fix-step-func-10 Commit report: 65bed16 Test service: datadog-ci-tests

:white_check_mark: 0 Failed, 2522 Passed, 0 Skipped, 2m 12.08s Total duration (1m 29.18s time saved)