-
Notifications
You must be signed in to change notification settings - Fork 408
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: Fix issue with strip_prefixes #647
Conversation
@BVMiko - Nice catch! Could you add a test case? Something like: def test_api_gateway_request_path_equals_strip_prefix():
# GIVEN a strip_prefix matches the request path
app = ApiGatewayResolver(strip_prefixes=["/foo"])
event = {"httpMethod": "GET", "path": "/foo"}
@app.get("/")
def base():
return {}
# WHEN calling the event handler
# WITH a route "/"
result = app(event, {})
# THEN process event correctly
assert result["statusCode"] == 200
assert result["headers"]["Content-Type"] == content_types.APPLICATION_JSON Regarding for the fix, i guess it could also default to |
@BVMiko - FYI, Heitor will be about for 5 weeks. How critical would a fix for this be? |
For now I have a workaround in place which can remain until this issue is resolved: app = ApiGatewayResolver(strip_prefixes=["/foo"])
@app.get("/")
def base():
return {}
def lambda_handler(event, context):
if event['path'] == '/foo':
event['path'] = '/foo/'
return app.resolve(event, context) |
Codecov Report
@@ Coverage Diff @@
## develop #647 +/- ##
===========================================
- Coverage 99.97% 99.93% -0.05%
===========================================
Files 116 116
Lines 4846 4821 -25
Branches 265 266 +1
===========================================
- Hits 4845 4818 -27
- Misses 0 1 +1
- Partials 1 2 +1
Continue to review full report at Codecov.
|
@BVMiko - would you be able to include a test like this into the api gateway handler test suite? |
@michaelbrewer: The test has been added |
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.
LGTM thanks @BVMiko
Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience! |
…tools-python into develop * 'develop' of https://github.com/awslabs/aws-lambda-powertools-python: docs(event-handler): document catch-all routes (aws-powertools#705) chore: add python 3.9 support docs: add team behind it and email ISSUE-693: Use ExpressionAttributeNames in _put_record (aws-powertools#697) feat(validator): include missing data elements from a validation error (aws-powertools#686) chore(deps-dev): bump mkdocs-material from 7.2.8 to 7.3.0 (aws-powertools#695) chore(deps-dev): bump mkdocs-material from 7.2.6 to 7.2.8 (aws-powertools#682) chore(deps-dev): bump flake8-bugbear from 21.4.3 to 21.9.1 (aws-powertools#676) chore(deps): bump boto3 from 1.18.38 to 1.18.41 (aws-powertools#677) chore(deps-dev): bump radon from 4.5.2 to 5.1.0 (aws-powertools#673) chore(deps): bump boto3 from 1.18.32 to 1.18.38 (aws-powertools#671) refactor(data-classes): clean up internal logic for APIGatewayAuthorizerResponse (aws-powertools#643) fix(data-classes): use correct asdict funciton (aws-powertools#666) chore(deps-dev): bump xenon from 0.7.3 to 0.8.0 (aws-powertools#669) chore: bump to 1.20.2 fix: Fix issue with strip_prefixes (aws-powertools#647) chore(deps-dev): bump mkdocs-material from 7.2.4 to 7.2.6 (aws-powertools#665) chore(deps): bump boto3 from 1.18.26 to 1.18.32 (aws-powertools#663) chore(deps-dev): bump pytest from 6.2.4 to 6.2.5 (aws-powertools#662) chore(license): Add THIRD-PARTY-LICENSES (aws-powertools#641)
Issue #, if available: #646
Description of changes:
After removing path prefixes, allow an empty path to return
"/"
so that it will match a normal routing rule.Checklist
Breaking change checklist
RFC issue #:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.