Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Duplicate Payload Object in Input from SFN #592

Merged
merged 2 commits into from
Nov 20, 2024

Conversation

avedmala
Copy link
Contributor

@avedmala avedmala commented Nov 20, 2024

What does this PR do?

Adds a guard clause around the code where we unpack the Payload object if it exists in the Step Functions event. There's an edge case where it isn't a Legacy Lambda object but customer's data may have a Payload in there

Motivation

Python layer already checks this, we forgot to add it for node

Testing Guidelines

Tested in staging, here's a sample trace that shows how this fixes the trace merging

Screenshot 2024-11-20 at 5 22 06 PM

Additional Notes

Types of Changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog
  • This PR passes the integration tests (ask a Datadog member to run the tests)

@avedmala avedmala requested a review from a team as a code owner November 20, 2024 22:15
Comment on lines 80 to 81
typeof event.Payload === "object" &&
(typeof event.Payload._datadog === "object" || this.isValidContextObject(event.Payload))
Copy link
Contributor

@nhulston nhulston Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: We could make this safer by adding optional chaining, i.e.

typeof event?.Payload === "object".

Unless we already know for sure that event is defined, then we don't have to do this

Comment on lines +207 to +209
execution_id: event.Execution.Id,
state_entered_time: event.State.EnteredTime,
state_name: event.State.Name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same micro nit here, might be safer to do event?.Execution?.Id and so on

Comment on lines 219 to 224
typeof context.Execution === "object" &&
typeof context.Execution.Id === "string" &&
typeof context.State === "object" &&
typeof context.State.EnteredTime === "string" &&
typeof context.State.Name === "string"
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same micro nit. Ignore me if you know 100% these fields always exist

@avedmala avedmala merged commit 58da6cd into main Nov 20, 2024
25 checks passed
@avedmala avedmala deleted the avedmala/sfn-payload-guard branch November 20, 2024 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants