Skip to content

Commit a099a5a

Browse files
committed
bugfix: request data for flask was not attached
1 parent 97593a0 commit a099a5a

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

sentry_sdk/integrations/flask.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ def _before_request(*args, **kwargs):
8686
get_current_hub().capture_internal_exception()
8787

8888
def _get_request_info():
89-
{
90-
'url': '%s://%s%s' % (request.scheme, urlparts.host, request.path),
91-
'query_string': urlparts.query,
89+
return {
90+
'url': '%s://%s%s' % (request.scheme, request.host, request.path),
91+
'query_string': request.query_string,
9292
'method': request.method,
9393
'data': request.get_data(cache=True, as_text=True, parse_form_data=True),
9494
'headers': dict(request.headers),

tests/integrations/conftest.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ class TestClient(Client):
66
def __init__(self):
77
pass
88

9-
def capture_internal_exception(self, error=None):
10-
if not error:
11-
raise
12-
raise error
13-
149
dsn = 'LOL'
1510
options = {'with_locals': False, 'release': 'fake_release', 'environment': 'fake_environment', 'server_name': 'fake_servername'}
1611
_transport = None
@@ -31,6 +26,17 @@ def close(self):
3126
sentry_sdk.init()
3227
sentry_sdk.get_current_hub().bind_client(test_client)
3328

29+
@pytest.fixture(autouse=True)
30+
def reraise_internal_exceptions(monkeypatch):
31+
def capture_internal_exception(error=None):
32+
if not error:
33+
raise
34+
raise error
35+
36+
monkeypatch.setattr(sentry_sdk.get_current_hub(),
37+
'capture_internal_exception',
38+
capture_internal_exception)
39+
3440

3541
@pytest.fixture
3642
def capture_exceptions(monkeypatch):

tests/integrations/flask/test_flask.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ def test_has_context(app):
3535
def index():
3636
with configure_scope() as scope:
3737
assert scope._data['transaction'] is 'index'
38+
assert scope._data['request']['data'] == ''
39+
assert scope._data['request']['url'] == 'http://localhost/'
3840

3941
return 'ok'
4042

0 commit comments

Comments
 (0)