fix: signal rejected IPR response emails (#7584)

This commit is contained in:
Jennifer Richards 2024-06-24 12:22:01 -03:00 committed by GitHub
parent 6fbd8473f2
commit 77f61f0f45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View file

@ -789,7 +789,9 @@ Subject: test
mock_process_response_email.side_effect = None mock_process_response_email.side_effect = None
mock_process_response_email.return_value = None # rejected message mock_process_response_email.return_value = None # rejected message
ingest_response_email(message) # should _not_ send an exception email on a clean rejection with self.assertRaises(EmailIngestionError) as context:
ingest_response_email(message)
self.assertIsNone(context.exception.as_emailmessage()) # should not send an email on a clean rejection
self.assertTrue(mock_process_response_email.called) self.assertTrue(mock_process_response_email.called)
self.assertEqual(mock_process_response_email.call_args, mock.call(message)) self.assertEqual(mock_process_response_email.call_args, mock.call(message))
mock_process_response_email.reset_mock() mock_process_response_email.reset_mock()

View file

@ -92,8 +92,10 @@ def generate_draft_recursive_txt():
def ingest_response_email(message: bytes): def ingest_response_email(message: bytes):
from ietf.api.views import EmailIngestionError # avoid circular import from ietf.api.views import EmailIngestionError # avoid circular import
try: try:
process_response_email(message) result = process_response_email(message)
except Exception as err: except Exception as err:
# Message was rejected due to an unhandled exception. This is likely something
# the admins need to address, so send them a copy of the email.
raise EmailIngestionError( raise EmailIngestionError(
"Datatracker IPR email ingestion error", "Datatracker IPR email ingestion error",
email_body=dedent("""\ email_body=dedent("""\
@ -104,3 +106,8 @@ def ingest_response_email(message: bytes):
email_original_message=message, email_original_message=message,
email_attach_traceback=True, email_attach_traceback=True,
) from err ) from err
if result is None:
# Message was rejected due to some problem the sender can fix, so bounce but don't send
# an email to the admins
raise EmailIngestionError("IPR response rejected", email_body=None)