Review a Notification-Sending Change for Duplicate Sends, Preference Bypass, and Wrong Recipients
Review the following code change, which sends notifications (email, SMS, push, or in-app messages) to users. Look for the failure modes that are hard to undo once a message has gone out. For each finding, give the file and line, the concrete scenario that triggers it, the user-visible consequence, and a specific fix. Rank findings by severity, and state "no issue found" for any category that is clean. Don't pad the list. Check these categories: 1. Duplicate sends: Can a retry, queue redelivery, double click, cron overlap, or replayed event send the same message twice? Is there a deduplication or idempotency key, and is it recorded before or after the provider call? Say what happens if the process crashes between the send and the write. 2. Preference and consent bypass: Is the user's opt-out, unsubscribe, channel preference, or quiet-hours setting checked at send time, or only when the job was queued? Are transactional and marketing messages correctly separated? Does a bulk or admin path skip the check? 3. Wrong recipient: Could stale cached contact data, a reused or reassigned email or phone number, or an account merge route the message to the wrong person? Is the recipient looked up by stable user ID? 4. Template safety: Is user-controlled data escaped for the output format (HTML email, SMS length, push payload limits)? Can a missing variable produce a broken or misleading message, and does rendering fail closed or send anyway? 5. Volume and blast radius: Is there a per-user and global rate cap, a batch size limit, and a kill switch? What stops a bug from emailing the whole user table? 6. Sensitive content: Does the message body or a log line include secrets, reset tokens, or personal data that shouldn't leave the system or be stored in provider logs? 7. Failure handling: Are provider errors classified (retryable or permanent, such as bounce or invalid number)? Are permanent failures suppressed for future sends? --- When to use it: on any pull request that adds a new notification, changes who receives one, or touches the sending pipeline, queue consumers, or templates. Messages can't be recalled, so these bugs deserve review before merge, not after. How to adapt it: paste the diff plus the surrounding sender, queue, and template code, because most duplicate-send bugs only show up with context. For SMS-only or push-only systems, drop the HTML-escaping part of item 4 and add carrier length and encoding limits. If your organization has legal consent requirements, add them to item 2 explicitly rather than expecting the model to know them. Example input: a diff adding a "your export is ready" email, sent from a job that is retried up to three times on any exception and calls the email provider before marking the export as notified. What good output looks like: a top-severity finding that a timeout after a successful provider call triggers a retry and sends a second email, with a fix to write a send record keyed by export ID first and pass that key to the provider if it supports idempotency. Then a finding on whether the export owner's email is read at send time, and explicit "no issue found" lines for the clean categories.
Sign in to upvote this prompt.