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

Use dict get instead of direct dict access in Flask init #23

Merged
merged 1 commit into from
Sep 19, 2018

Conversation

nathanleclaire
Copy link
Contributor

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.

"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', '')

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?

@nathanleclaire nathanleclaire force-pushed the nathanleclaire.use_dict_get branch from b6e6e87 to 7b8c50d Compare September 19, 2018 22:13
Copy link

@maplebed maplebed left a 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)

Copy link
Contributor

@asdvalenzuela asdvalenzuela left a 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

@@ -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()
Copy link
Contributor

@asdvalenzuela asdvalenzuela Sep 19, 2018

Choose a reason for hiding this comment

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

can't lower None

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops!

@@ -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()
Copy link
Contributor

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'?

@nathanleclaire nathanleclaire force-pushed the nathanleclaire.use_dict_get branch from 7b8c50d to a32e95b Compare September 19, 2018 22:22
@nathanleclaire
Copy link
Contributor Author

Closes #22

@nathanleclaire nathanleclaire force-pushed the nathanleclaire.use_dict_get branch from a32e95b to 76e4ae0 Compare September 19, 2018 22:23
@tredman
Copy link
Contributor

tredman commented Sep 19, 2018

@nathanleclaire also need to update version in setup.py

@nathanleclaire nathanleclaire force-pushed the nathanleclaire.use_dict_get branch from 76e4ae0 to 7a29757 Compare September 19, 2018 22:43
@nathanleclaire nathanleclaire merged commit dc0e83f into master Sep 19, 2018
@nathanleclaire nathanleclaire deleted the nathanleclaire.use_dict_get branch September 19, 2018 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants