Skip to content

Commit

Permalink
Skip xfn->Lambda context propagation if custom Payload is used
Browse files Browse the repository at this point in the history
  • Loading branch information
lym953 committed Sep 12, 2024
1 parent 5ef1845 commit a9f365f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/commands/stepfunctions/__tests__/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,32 @@ describe('stepfunctions command helpers tests', () => {
expect(shouldUpdateStepForTracesMerging(step, context, 'Lambda Invoke')).toBeTruthy()
})

test('custom payload field not using JsonPath expression', () => {
const step: StepType = {
Type: 'Task',
Resource: 'arn:aws:states:::lambda:invoke',
Parameters: {
FunctionName: 'arn:aws:lambda:sa-east-1:425362991234:function:unit-test-lambda-function',
Payload: '{"action": "service/delete_customer"}',
},
End: true,
}
expect(shouldUpdateStepForTracesMerging(step, context, 'Lambda Invoke')).toBeFalsy()
})

test('custom payload field using JsonPath expression', () => {
const step: StepType = {
Type: 'Task',
Resource: 'arn:aws:states:::lambda:invoke',
Parameters: {
FunctionName: 'arn:aws:lambda:sa-east-1:425362991234:function:unit-test-lambda-function',
'Payload.$': '{"customer.$": "$.customer"}',
},
End: true,
}
expect(shouldUpdateStepForTracesMerging(step, context, 'Lambda Invoke')).toBeFalsy()
})

test('none-lambda step should not be updated', () => {
const step: StepType = {
Type: 'Task',
Expand Down
3 changes: 2 additions & 1 deletion src/commands/stepfunctions/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ check out https://docs.datadoghq.com/serverless/step_functions/troubleshooting/\
}

// payload field not set
if (!step.Parameters.hasOwnProperty('Payload.$')) {
if (!step.Parameters.hasOwnProperty('Payload.$') && !step.Parameters.hasOwnProperty('Payload')) {
return true
}

Expand Down Expand Up @@ -228,6 +228,7 @@ export type StepType = {

export type ParametersType = {
'Payload.$'?: string
Payload?: string
FunctionName?: string
StateMachineArn?: string
TableName?: string
Expand Down

0 comments on commit a9f365f

Please sign in to comment.