I build back-office systems for small Italian companies: CRMs, booking flows, the boring machinery that sends the right email to the right person. I write most of that code with an AI assistant. I'm not hiding it, it's how I work.
And there is one bug my assistant writes almost every time, in every project, unless I stop it. It looks like good engineering. It passes the tests. And in production it sends your customer the same email twice.
The code that looks right
Ask an AI to "send the confirmation email, and make it robust", and you'll get something like this:
async function sendConfirmation ( booking : Booking ) { for ( let attempt = 1 ; attempt <= 3 ; attempt ++ ) { try { await emailProvider . send ( confirmationFor ( booking )); return ; } catch ( err ) { if ( attempt === 3 ) throw err ; await sleep ( 1000 * attempt ); } } }
Enter fullscreen mode
Exit fullscreen mode
Retries, backoff, a final throw. A reviewer would approve it. So would I, on a tired day.
The problem is hidden in that catch .…