The Regex That Trusted Email — JavaScript Bug Hunt
Inspired by the bounce storms behind every "we emailed you a receipt" pipeline: the validator is /.+@.+/, so a@b@c, "has spaces"@x and domains without a dot…
- Language: JavaScript
- Layer: Backend
- Difficulty: Easy
- Concepts: Validation, Regex
- Modelled on: Email-validation lore
- Visible tests: normal addresses pass; double @ and spaces fail; dotless domains and short TLDs fail
- Reward: 50 XP for a complete fix
Incident
- Severity: SEV-3
- Time to fix: 10 minutes, the target for an easy incident
Failing checks on the shipped build
- double @ and spaces fail — expected a truthy value but got false
- dotless domains and short TLDs fail — expected a truthy value but got false
How to work this incident
- Read the report: write down the expected behaviour and the actual one in a sentence each.
- Reproduce it: run the visible tests and find the failing check that matches the report.
- Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
- Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
- Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.
Briefing
Inspired by the bounce storms behind every "we emailed you a receipt" pipeline: the validator is /.+@.+/, so a@b@c, "has spaces"@x and domains without a dot all get queued, bounce, and tank the sender reputation.
Tighten emailCheck.js to the sane subset.
Bug report
BUG-MX · Reported by: deliverability
isValid(email) — pragmatic rules:
- exactly one "@", no whitespace anywhere
- local part non-empty
- domain contains at least one ".", with a TLD of 2+ letters
Observed: 12% of the queue is structurally impossible addresses.
Logs
[smtp] 550 loop detected for "ceo@corp@corp"The code as shipped
src/mail/emailCheck.js (editable)
// Structural email validation.
exports.isValid = function (email) {
return /.+@.+/.test(email);
};
Open the hunt to start the incident clock, edit the files, run the visible tests and submit against the hidden ones, then write the root cause down. More JavaScript bug hunts.