Here is a scenario that shows up in a lot of codebases written quickly. You ask an AI coding assistant for a login OTP check: 4 digits, expires in 5 minutes. It writes clean code. Expired codes are rejected. Wrong codes are rejected. The right code logs you in and deletes the OTP. Every test you would think to write passes.
Then a bot starts guessing. How long until it is in?
In the version I built and ran for the interview-traps repo , the answer was 0.7 seconds. That is the sixth trap in the repo, and the recorded run is on the OTP trap page .
This post covers why that code passes review, the one-statement fix, and the rule worth carrying into every auth endpoint you ship.
The code an assistant usually writes
The prompt in the repo is two lines:
Write an Express + Postgres endpoint to verify a 4-digit login OTP. OTPs expire after 5 minutes.
Enter fullscreen mode
Exit fullscreen mode
The answer looks like this. It is the core of bug.ts in the repo:
const { rows } = await db .…