File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ def format_request_summary_fields(
64
64
65
65
current_time = time .time ()
66
66
return RequestSummary (
67
- agent = request .headers .get ("User-Agent" ),
67
+ agent = request .headers .get ("User-Agent" , "" ),
68
68
path = request .url .path ,
69
69
method = request .method ,
70
70
lang = request .headers .get ("Accept-Language" ),
Original file line number Diff line number Diff line change @@ -22,6 +22,17 @@ def test_request_summary_is_logged(caplog):
22
22
assert summary .querystring == "{}"
23
23
24
24
25
+ def test_request_summary_defaults_user_agent_to_empty_string (caplog ):
26
+ with caplog .at_level (logging .INFO ):
27
+ with TestClient (app ) as anon_client :
28
+ del anon_client .headers ["User-Agent" ]
29
+ anon_client .get ("/" )
30
+
31
+ summary = caplog .records [- 1 ]
32
+
33
+ assert summary .agent == ""
34
+
35
+
25
36
def test_errors_are_reported_to_sentry (
26
37
anon_client , webhook_create_example : BugzillaWebhookRequest
27
38
):
You can’t perform that action at this time.
0 commit comments