-
Notifications
You must be signed in to change notification settings - Fork 404
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: Fixed event matcher to focus on properties specific to web requests (v1/ALB and v2) #2863
base: main
Are you sure you want to change the base?
fix: Fixed event matcher to focus on properties specific to web requests (v1/ALB and v2) #2863
Conversation
…ed test for API Gateway Lambda authorizers, fixed typo Signed-off-by: mrickard <maurice@mauricerickard.com>
… keys, but changed to bail early when a key isn't found Signed-off-by: mrickard <maurice@mauricerickard.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2863 +/- ##
==========================================
- Coverage 97.27% 97.22% -0.06%
==========================================
Files 296 296
Lines 46625 46552 -73
==========================================
- Hits 45354 45259 -95
- Misses 1271 1293 +22
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: mrickard <maurice@mauricerickard.com>
…, renamed methods to focus on proxying, folded ALB check into Gateway v1 Signed-off-by: mrickard <maurice@mauricerickard.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic has been pared down quite a lot. Are we certain this won't regress on the driver for the initial refactor of this file?
@bizob2828 That's a valid concern. The initial driver was for support for API Gateway V2 events, which are structured differently from V1, particularly regarding the Initially we focused on identifying v1 vs v2 events in this commit. While this takes a similar approach to the current PR, it checks event version first. That could result in non-web requests being matched as web requests, as non-web-requests can use API Gateway v1 and v2. This subsequent fix was driven by a similar issue to the current issue: a non-web request was identified as a web request. The fix matched on more event properties, and better identified web requests because of that, but it was too restrictive, excluding ALB web events from being identified as web requests. Subsequent fixes added explicit support for v1 REST events and for ALB events. These focused on those event sources, but did not focus explicitly on identifying web from non-web requests. (ALB matching is removed for this PR because its web-request signature is the same as that of API Gateway v1.) One distinct advantage of all of these fixes is that they've added tests we can use to check whether or not the matching behaves as expected. Those are still passing for this refactoring. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one tiny suggestion on the code comments, but otherwise LGTM
Co-authored-by: Bob Evans <robert.evans25@gmail.com>
Description
Customer reported an error when triggering an instrumented Lambda function via
APIGatewayRequestAuthorizerEvent
.This PR makes the event matching more restrictive to avoid false positives.
How to Test
Added event fixture to
test/unit/serverless/fixtures.js
and assertions totest/unit/serverless/utils.test.js
. Added unit test for API Gateway V2 websocket events intest/unit/serverless/api-gateway-v2-websocket.test.js
Related Issues
Closes #2857
Closes NR-354739