-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Set raw_body to None if no HTTP body was sent #506
Conversation
Codecov Report
@@ Coverage Diff @@
## master #506 +/- ##
==========================================
- Coverage 94.01% 94.01% -0.01%
==========================================
Files 18 18
Lines 2941 2939 -2
Branches 380 380
==========================================
- Hits 2765 2763 -2
Misses 129 129
Partials 47 47
Continue to review full report at Codecov.
|
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.
Implementation looks fine. I am curious as to why you chose raw body value as None
instead of setting it as an empty string? I read the bug report and it looked like you were contemplating either None
or empty string.
I don't have a strong preference either way. The two things that swayed me were:
Do you think it should default to an empty string? |
I was not sure either, which is why I asked. The way I see it is returning a string is nice because you do not have to do any special casing for |
I could not get API Gateway to send the empty string. I think this is the default behavior of the lambda_proxy integration for API gateway
Flask sets it to the empty string (or more specifically an empty bytestring |
Given those reasons, I am leaning toward empty string or rather empty bytestring for the raw body. That is also assuming it won't break anyone. |
Cool, pushed a change to defaults to the empty bytestring. I don't believe this breaks anyone. The original issue was that sending an empty body and trying to access |
Interesting... The failures are due to the fact that This is actually an independent problem separate from this change. You can trigger this failure by trying to call It was never my intent to map internal class attributes as part of the
Which means my initial thoughts of just remove keys that start with
What do you all think? |
Agreed. I think it is fine to not include the
|
@app.route('/')
def broken():
app.current_request.raw_body
return app.current_request.to_dict() This app currently crashes. If you omit the line Lines 312 to 323 in f787f3e
When you access Lines 278 to 287 in f787f3e
However if you don't access the
|
This also includes an update the local.py so we get consistent behavior when no HTTP body is provided. Fixes aws#503.
Changed based on the PR feedback.
Cool that makes sense to me. I will take a look at the code. |
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.
Cool. Looks good to me. 🚢. I think hypothesis testing is not necessarily required for this PR, but we should add it in the future.
This also includes an update the local.py so we get
consistent behavior when no HTTP body is provided.
Fixes #503.