Code RoomNotification stops on first failure
MediumPrep Room Coding #1951

Notification stops on first failure

Code reviewDistributed systemsMid–Senior~18 min

Review this Python function that fans out a notification to many recipients. `send` calls an email provider and may raise on a single bad address or a transient error.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 18 min
Mark a line and say what kind of problem it is.0 findings
1def send(recipient, message):
2 resp = provider.send_email(to=recipient, body=message)
3 resp.raise_for_status() # raises on 4xx/5xx
4 
5def notify_all(recipients, message):
6 sent = 0
7 for r in recipients:
8 send(r, message)
9 sent += 1
10 logging.info("notified %d recipients", sent)
11 return sent
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.