Add internal exception handling to _send_error_notification#175
Add internal exception handling to _send_error_notification#175
Conversation
Wrap the HTTP request in try/except so the function never raises. A notification helper should not propagate exceptions to its caller. Remove the now-redundant try/except wrapper in triage_issue(). Fixes #162
Review by KaiReview: #175The design decision is sound — a notification helper that can raise defeats its purpose. The implementation is mostly clean, with one meaningful finding. Warning: Exception details silently discarded
The original caller used except Exception:
log.warning(
"Failed to send triage error notification for %s#%d",
metadata.repo,
metadata.number,
)The why of the failure (network refused, TLS error, DNS failure, etc.) is completely lost. When notifications silently stop working in production, you'll have no way to diagnose it from logs. Fix: add log.warning(
"Failed to send triage error notification for %s#%d",
metadata.repo,
metadata.number,
exc_info=True,
)Suggestion: Minor log message inconsistencyThe non-200 branch ( TestsThe three new tests cover the stated contract. One note: the Overall: Approve with the |
Review by KaiReview: #175 (updated)The prior review's primary finding — No new findingsThe diff is clean:
The non-200 log message still lacks repo/issue context (raised as low priority in the prior review), but that's a pre-existing gap the author has already seen. Approve. The refactor is correct, the contract is enforced, and the key logging regression is fixed. |
Summary
Move exception handling into
_send_error_notification()so it never raises. A notification helper that can propagate exceptions defeats its own purpose - it exists to tell the user something went wrong, and a failure in that notification should be logged and swallowed, not bubbled up.Changes
_send_error_notification()triage_issue()callerTest plan
test_does_not_raise_on_connection_error- ConnectionError caught, function returns cleanlytest_does_not_raise_on_timeout- TimeoutError caught, function returns cleanlytest_logs_warning_on_failure- warning logged with repo and issue numbermake checkcleanFixes #162