Skip to content

Safer Flask teardown request function #75

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

Closed
luyun-aa opened this issue Aug 5, 2018 · 5 comments
Closed

Safer Flask teardown request function #75

luyun-aa opened this issue Aug 5, 2018 · 5 comments
Labels

Comments

@luyun-aa
Copy link

luyun-aa commented Aug 5, 2018

Ref: http://flask.pocoo.org/docs/0.12/reqcontext/#callbacks-and-errors

Flask requests that teardown_request function should never fail. The request teardown function implementation in XRay SDK is not robust enough because if before_request is not executed, context.current_segment would return None. Any operation on the "None" segment would fail.

@luyun-aa luyun-aa changed the title Safer Flask km,. Safer Flask teardown request function Aug 5, 2018
@haotianw465
Copy link
Contributor

Thank you for your feedback. Just want to clarify do you mean this method https://github.com/aws/aws-xray-sdk-python/blob/master/aws_xray_sdk/ext/flask/middleware.py#L58

@luyun-aa
Copy link
Author

Ah no, I'm referring to XRayMiddleware. _handle_exception (https://github.com/aws/aws-xray-sdk-python/blob/master/aws_xray_sdk/ext/flask/middleware.py#L73), because it's registered to teardown_request in XRayMiddleware.__init__.

@haotianw465
Copy link
Contributor

Thank you for the clarification. We will work on a fix soon.

@haotianw465
Copy link
Contributor

This is fixed in 2.0.0.

@luyun-aa
Copy link
Author

Thanks

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

No branches or pull requests

2 participants