-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Auto-decode the HTTP request body based on the Content-Encoding HTTP header #4017
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
Conversation
|
A small note about a minor refactoring included this PR: I removed the Why? Because I had to make use of
I picked this last option, as it was easy to mock Flask global |
7b38df1 to
64d561f
Compare
hawflau
left a comment
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.
Thanks for the contribution!. Seems there's a pylint violation causing one of the check failures. Could you please fix that first?
pylint --rcfile .pylintrc samcli
************* Module samcli.local.apigw.local_apigw_service
samcli/local/apigw/local_apigw_service.py:275:4: R0912: Too many branches (13/12) (too-many-branches)
I'll continue review the remaining of the PR.
|
Hi @hawflau Thank you for your comment. |
|
Hi @Lucas-C yeah, splitting the function into two parts makes sense. The simplest you can do is to just factor out the part you added into a new method |
|
@hawflau: thank you for your answer. |
|
The On my computer Could you provide some advice on this please? |
|
I see that the |
|
@Lucas-C I checked on of the jobs runs and looks like it just formatting (at least for that run). Could you update the PR with the I am going through our PR backlog and adding ones to review to my list. Will add this one to my list and targeting to have reviews out by end of the week for ones I assign to myself. |
30cc4c8 to
822c888
Compare
I did jut that yesterday :) |
|
@Lucas-C I see the failures you posted above now. I remember having some troubles with this a while back and think that is why we mocked out Doing some quick googling, https://stackoverflow.com/questions/17375340/testing-code-that-requires-a-flask-app-or-request-context might be helpful. Basically what is happening there is some context that flask (or WSGI) needs and it's not setup correctly within the test causing the failures. We could try to dig deeper into the "right" way to do this in the test or just mock out similar to how we did previous. It is weird that this only happens on the CI system though. |
3d15a41 to
c579783
Compare
Yeah, it's weird, tests pass fine on my computer. I found a way to solve the problem in the CI pipeline by using Flask-Testing, which I added as a dependency in |
|
Thanks for fixing the issues @Lucas-C. The only worry that I have is the library that you've added. It seems it is not maintained anymore (last commit from 2020). Can we somehow resolve this issue by overriding |
OK, I understand if you don't want to introduce this library as a dependency. Using it solved an issue that only appears in the CI pipeline, so it is quite annoying to debug... I have already spent quite a few hours on this PR, and asked for help on how to handle those failing tests 2 months ago, without any practical solution being suggested so far... And the solution I came with is apparently not satisfying. Could the maintainers of this project please give some assistance here? I'm a bit sad if this PR does not get merged after the time I spent on it, but I don't to fall for the sunk cost fallacy 😊 |
|
@Lucas-C thank you very much for your efforts, we really appreciate the community contributions for this project! I feel your pain and I am doing my best to help you fix the issues and merge this PR. I've fixed unit test issues and removed that library but I can't push to your fork. Can you give me write access to your fork so that I can push my updates? Thanks! |
|
Sure, I gave you write permission on it @mndeveci |
mndeveci
left a comment
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 a lot for your contribution 🥳
moelasmar
left a comment
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.
Could you please include an integration test cases to cover your changes!!
67e2603 to
75e8d15
Compare
|
The Error logs: @Lucas-C do you know what the reason could be? |
|
Closing as this looks stale. If you are still interested in contributing, feel free to re-open or create a new PR. |
Which issue(s) does this change fix?
This was not reported so far, based on a quick research among this repository issues.
Why is this change necessary?
Currently AWS SAM does not replicate API Gateway behaviour of auto-decoding a gzip-ed payload.
How does it address the issue?
This PR ensures that the Flask
request.streamis decoded with thegzipstandard Python module if the request HTTP headerContent-EncodingisgzipWhat side effects does this change have?
None
Mandatory Checklist
PRs will only be reviewed after checklist is complete
Note : I have only added unit tests so far. I can add integration tests upon request.
make prpassesNote : I'm not sure how best to fix this Pylint check:
make update-reproducible-reqsif dependencies were changedBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.