Skip sfn->Lambda context injection if custom Payload is used without $ #1450
+28
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
If a Lambda function in a State Machine has a custom
Payload
defined using"Payload": ...
, e.g.,then context injection for the Step Function will fail with the error:
This is because our instrumentation code will add a field
"Payload.$": ...
, which duplicates with"Payload": ...
. Right now we only check for custom"Payload.$": ...
(with$
, i.e. using JSONPath) but don't check for custom"Payload": ...
.What
Also skip context injection when a custom
"Payload": ...
field is used (without$
)Testing
Automated testing
Pass the added test, which would fail without the changes on
helpers.ts
Manual testing
Steps:
Payload
field of a Lambda function to what's shown in "Problem" sectiondatadog-ci stepfunctions instrument
Result: a warning is printed as expected
Notes
Payload
field as long as it doesn't containExecution
orState
field inside. But I want to first merge this PR to make the existing behavior more clear, so the changes in future PRs will be more clear so the PRs will be easier to review.Review checklist