-
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
raw_body property inconsistency #503
Labels
Comments
Note that I commented out the setting of body to "{}" here to validate |
Confirmed bug: @app.route('/')
def index():
return {'hello': repr(app.current_request.raw_body)}
I think setting this value to None/empty string makes sense for both Thanks for reporting. |
jamesls
added a commit
to jamesls/chalice
that referenced
this issue
Aug 30, 2017
This also includes an update the local.py so we get consistent behavior when no HTTP body is provided. Fixes aws#503.
jamesls
added a commit
to jamesls/chalice
that referenced
this issue
Aug 31, 2017
This also includes an update the local.py so we get consistent behavior when no HTTP body is provided. Fixes aws#503.
jamesls
added a commit
to jamesls/chalice
that referenced
this issue
Aug 31, 2017
This also includes an update the local.py so we get consistent behavior when no HTTP body is provided. Fixes aws#503.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When no body is sent, and
app.current_request.raw_body
is used, there is inconsistent behavior between local Chalice testing and actually how it runs in Lambda.For local testing, if no body is sent
self._body
is getting set to a string:{}
However, when no body is provided in an actual call to API gateway,
self._body
isNone
and there is an unhandled AttributeError exception when this executes:self._raw_body = self._body.encode('utf-8')
This effectively makes it hard for an app developer to gracefully handle a missing body from a call and will always yield a 500 error back to the user.
I personally see no reason to catch if body is None within
local.py
this effectively gives a false impression of how a request will be handled by Lambda itself. Instead the None type should be handled within theraw_body
property IMO.Relevant code in app.py:
Relevant code in local.py:
The text was updated successfully, but these errors were encountered: