-
Notifications
You must be signed in to change notification settings - Fork 39
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
Use dict get instead of direct dict access in Flask init #23
Conversation
beeline/middleware/flask/__init__.py
Outdated
"request.query": environ['QUERY_STRING'] | ||
"request.user_agent": environ.get('HTTP_USER_AGENT', ''), | ||
"request.scheme": environ.get('wsgi.url_scheme', ''), | ||
"request.query": environ.get('QUERY_STRING', '') |
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.
How about using None instead of the empty string if those fields don't exist?
b6e6e87
to
7b8c50d
Compare
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.
also please bump the version number (patch seems like the right bump)
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.
one comment to fix otherwise good
beeline/middleware/flask/__init__.py
Outdated
@@ -26,17 +26,17 @@ def __init__(self, app): | |||
self.app = app | |||
|
|||
def __call__(self, environ, start_response): | |||
trace_name = "flask_http_%s" % environ['REQUEST_METHOD'].lower() | |||
trace_name = "flask_http_%s" % environ.get('REQUEST_METHOD', None).lower() |
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.
can't lower None
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.
oops!
beeline/middleware/flask/__init__.py
Outdated
@@ -26,17 +26,17 @@ def __init__(self, app): | |||
self.app = app | |||
|
|||
def __call__(self, environ, start_response): | |||
trace_name = "flask_http_%s" % environ['REQUEST_METHOD'].lower() | |||
trace_name = "flask_http_%s" % environ.get('REQUEST_METHOD', None).lower() |
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.
.lower()
will raise an exception if the value is None
- maybe default to 'unknown_method'
?
7b8c50d
to
a32e95b
Compare
Closes #22 |
a32e95b
to
76e4ae0
Compare
@nathanleclaire also need to update version in |
76e4ae0
to
7a29757
Compare
Still need to understand why the value wasn't present as expected and how to work around that, but this will at least give empty strings instead of rendering the Beeline unusable.