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: Improved AWS Lambda event detection #2498

Merged
merged 2 commits into from
Aug 21, 2024

Conversation

jsumners-nr
Copy link
Contributor

This PR resolves #2489.

) {
result = true
}
const v1Keys = [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't find any information on what AWS does when some field from this list is not included in the payload. Does it send with field: null? Or does it completely omit the field. We are assuming that it sends field: null with this implementation, because the v1 example shows some such fields.


// Event used when one Lambda directly invokes another Lambda.
// https://docs.aws.amazon.com/lambda/latest/dg/invocation-async-retain-records.html#invocation-async-destinations
const lambaV1InvocationEvent = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not completely convinced this is the only payload shape that Lambda sends with direct invocations. But I can't find any other documentation to prove that.

Copy link

codecov bot commented Aug 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.14%. Comparing base (0c2ee2f) to head (7409291).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2498      +/-   ##
==========================================
+ Coverage   96.20%   97.14%   +0.94%     
==========================================
  Files         288      288              
  Lines       45305    45314       +9     
==========================================
+ Hits        43586    44022     +436     
+ Misses       1719     1292     -427     
Flag Coverage Δ
integration-tests-cjs-18.x 73.88% <84.21%> (?)
integration-tests-cjs-20.x 73.88% <84.21%> (?)
integration-tests-cjs-22.x 73.93% <84.21%> (?)
integration-tests-esm-18.x 49.17% <84.21%> (?)
integration-tests-esm-20.x 49.17% <84.21%> (?)
integration-tests-esm-22.x 49.20% <84.21%> (?)
unit-tests-18.x 88.68% <100.00%> (+0.01%) ⬆️
unit-tests-20.x 88.68% <100.00%> (+0.01%) ⬆️
unit-tests-22.x 88.68% <100.00%> (+0.01%) ⬆️
versioned-tests-18.x 78.82% <84.21%> (-0.08%) ⬇️
versioned-tests-20.x 78.83% <84.21%> (-0.08%) ⬇️
versioned-tests-22.x 78.83% <84.21%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jsumners-nr
Copy link
Contributor Author

Opening this up for review, but I would feel better about this if we had a localstack based canary test.

@jsumners-nr jsumners-nr marked this pull request as ready for review August 20, 2024 14:54
@jsumners-nr
Copy link
Contributor Author

Well, I started an experiment to build out such a canary, but it won't work for us:

https://docs.localstack.cloud/user-guide/aws/lambda/

Lambda layers let you include additional code and dependencies in your Lambda functions. The LocalStack Pro image allows you to deploy Lambda Layers locally to streamline your development and testing process. The Community image also allows creating, updating, and deleting Lambda Layers, but they are not applied when invoking a Lambda function.

@bizob2828 bizob2828 self-assigned this Aug 21, 2024
Copy link
Member

@bizob2828 bizob2828 left a comment

Choose a reason for hiding this comment

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

are we certain all those fields from developer guide are you required? we went from a very naive check to a very rigid one.

@jsumners-nr
Copy link
Contributor Author

are we certain all those fields from developer guide are you required? we went from a very naive check to a very rigid one.

No. It's not clear. But what I'm getting from the docs is that the top-level object will always have those keys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Error when using lambda destination: Cannot read properties of undefined (reading 'pathname')
2 participants