Skip to content
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 issue with local mode bodiless responses causing clients to hang #540

Merged
merged 1 commit into from
Sep 20, 2017

Conversation

stealthycoin
Copy link
Contributor

fixes #525

@codecov-io
Copy link

codecov-io commented Sep 19, 2017

Codecov Report

Merging #540 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #540      +/-   ##
=========================================
+ Coverage   94.39%   94.4%   +<.01%     
=========================================
  Files          18      18              
  Lines        3107    3108       +1     
  Branches      397     397              
=========================================
+ Hits         2933    2934       +1     
  Misses        126     126              
  Partials       48      48
Impacted Files Coverage Δ
chalice/local.py 98.27% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c915880...7c1e32f. Read the comment docs.

Copy link
Member

@jamesls jamesls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, just had some small comments.

CHANGELOG.rst Outdated
@@ -2,6 +2,13 @@
CHANGELOG
=========

Next Release (TBD)
==================
* Fix issue with chalice local mode causing http clients to hang on responses
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line between header and changelog entry.

@@ -0,0 +1,93 @@
import socket
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm surprised flake8 didn't complain about this. Please use pep8 guidelines for grouping imports.

chalice/local.py Outdated
@@ -201,7 +201,7 @@ class NotAuthorizedError(LocalGatewayException):


class NoOptionsRouteDefined(LocalGatewayException):
CODE = 403
CODE = 200
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because thats what API gateway does. I missed it before but I noticed it when going over these the tests for cors cases. I can do this as a separate PR if you would prefer.

Copy link
Member

@jamesls jamesls Sep 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a test for it. I don't mind it in this PR, but we should have a test for this. Might also be good to have a separate commit for this with a description of why it's being changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing tests should have covered it and I corrected the tests while I was there anyway and thats when I noticed it was incorrect.

I added these assertions:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow. This is updating the code for an exception right? Those tests are for successful requests aren't they? Are you saying we were previously returning a 403 response when we should have been returning a 200?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exception is raised when there is no OPTIONS method defined on a route which LocalGateway exceptions are raised when the routes cannot process the request, so that is reasonable so far. The calling code can still generate the OPTIONS request that API Gateway would return and then send a successful response if there is a CORSConfig object on it. I missed that it was a success case somehow before. But looking at it again it seems like it should be decoupled entirely from that type of error since all the others exceptions like this are actual error cases. Whereas this one should be caught and turned into a successful response by auto-generating the CORS headers.

I will fix this in a separate PR.

Copy link
Member

@jamesls jamesls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OPTIONS generated by CORS doesn't work correctly in local
3 participants