Skip to content
Y
yTube.SITE v8.0.4
media / worlds / tools / internet oddities
YouTube / video information

The Bug That Passes Every Test.

Video information, playback and saved actions.

The Bug That Passes Every Test.

Description: Your code works. The tests pass. Most of us stop there.

But code that works and code you can live with are two different things. In this video we take one Django view that processes an order. It checks the balance, charges the user, creates the order and sends an email. Then we follow what happens once other people start touching it.

A teammate has to read the whole thing to change one line. A discount feature gets squeezed into the middle. Then a real bug shows up: a user gets charged and no order exists. The logs just say "order done".

So we fix it, one small change at a time:
- an error code the frontend can actually check
- transaction.atomic() so the charge and the order succeed or fail together
- sending the email in a background job, after the transaction commits
- logs that tell you which order, which user and which request
- clearer names and grouped steps

Nothing advanced. Each change takes a few minutes. Together they decide whether your team moves fast or spends its time fighting the codebase.

(You'll also spot select_for_update() and a serializer in the final version. They're on screen, but they get their own video.)

Chapters
0:00 Your code works. Is that enough?
0:18 A few weeks later
0:38 The bug: charged, but no order
0:49 Fix 1: error codes
1:00 Fix 2: one transaction
1:14 Fix 3: email in the background
1:33 Fix 4: logs that help
1:45 Fix 5: names and structure
1:55 Working code is only the start

What's the one thing you always catch in code review that no test ever catches? Tell us in the comments.

---

At Neszen we look at real backends and tell teams what's going to hurt first, before it does.
Backend Stability & Scale Readiness Review: https://review.neszen.com
Website: https://neszen.com

#django #python #backend Close description
      
Videos related to "The Bug That Passes Every Test."

Related videos are temporarily unavailable.

Try again, or come back later.