Skip to content

Commit a22556f

Browse files
committed
fix(pacer): Added more courts to pacer_to_cl_ids
- Loggers improved
1 parent 09a6eaa commit a22556f

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

cl/recap_email/app/app.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ def get_combined_log_message(email):
6565
subject = header["value"]
6666

6767
return (
68-
f"Email with {subject}, from {email['source']} to "
69-
f"{email['destination']}"
68+
f"Email ID {email['message_id']} with {subject}, "
69+
f"from {email['source']} to {email['destination']}"
7070
)
7171

7272

@@ -138,7 +138,7 @@ def get_cl_court_id(email):
138138
return map_pacer_to_cl_id(sub_domain)
139139

140140

141-
def log_invalid_court_error(response):
141+
def log_invalid_court_error(response, message_id):
142142
"""Checks if the response indicates an invalid court pk then send a report
143143
to Sentry.
144144
"""
@@ -149,7 +149,10 @@ def log_invalid_court_error(response):
149149
if "Invalid pk" in msg:
150150
match = re.search(r'Invalid pk "([^"]+)"', msg)
151151
if match:
152-
error_message = f"Invalid court pk: {match.group(1)}"
152+
error_message = (
153+
f"Invalid court pk: {match.group(1)} - "
154+
f"message_id: {message_id}"
155+
)
153156
sentry_sdk.capture_message(error_message, level="error")
154157
break
155158

@@ -185,7 +188,8 @@ def send_to_court_listener(email, receipt):
185188
# Gateway Timeout status codes.
186189
court_listener_response.raise_for_status()
187190

188-
log_invalid_court_error(court_listener_response)
191+
message_id = email.get("message_id")
192+
log_invalid_court_error(court_listener_response, message_id)
189193

190194
print(
191195
f"Got {court_listener_response.status_code=} and content "

cl/recap_email/app/pacer.py

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"nysb-mega": "nysb", # Remove the mega thing
77
"txs": "txsd", # Southern District Of Texas
88
"mow": "mowd", # Western District of Missouri
9+
"gas": "gasd", # Southern District of Georgia
10+
"cfc": "uscfc", # Court of Federal Claims
911
}
1012

1113
# Reverse dict of pacer_to_cl_ids

cl/tests/unit/test_recap_email_handler.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -289,5 +289,8 @@ def test_report_request_for_invalid_court(
289289
)
290290
app.handler(pacer_event_one, "")
291291
# The expected error message should be sent to Sentry.
292-
expected_error = "Invalid court pk: whla"
292+
expected_error = (
293+
"Invalid court pk: whla - "
294+
"message_id: 171jjm4scn8vgcn5vrcv4su427obcred7bekus81"
295+
)
293296
mock_sentry_capture.assert_called_with(expected_error, level="error")

0 commit comments

Comments
 (0)