Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk2 min

I Put 3 Bugs in This Pull Request. How Many Can You Catch?

Can you find three defects in a short money-transfer endpoint before reading the review?
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can you spot what’s wrong with code someone else wrote? Review the endpoint below before reading the explanations. If this were a real pull request, what would you flag before approving it?

Review the code first

The example is a simplified Python-style money-transfer endpoint. Try to identify three defects before scrolling to the findings.

As an Amazon Associate I earn from qualifying purchases.

def transfer(sender, receiver, amount: float):
    if sender.balance < amount:
        raise ValueError("Insufficient funds")

    sender.balance -= amount
    receiver.balance += amount

Ask yourself: what inputs should be allowed, what kind of number should represent money, and what could happen if two requests run at the same time?

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Bug 1: The amount is not validated

The code checks whether the sender has enough money, but it never requires the amount to be positive. A zero-value transfer is accepted, and a negative amount reverses the arithmetic: subtracting a negative number increases the sender’s balance, while adding it decreases the receiver’s.

Define the transfer’s input constraints explicitly and enforce them before changing either balance. For example, an application might require an amount greater than zero and impose a currency-specific precision rule. The exact constraints depend on the application; this snippet does not specify them.

Bug 2: A float is a poor default for money

The parameter is annotated as float. Binary floating-point cannot represent some decimal fractions exactly, so calculations can produce small precision differences. Python’s Python 3.11.17 Decimal documentation explains that values such as 1.1 and 2.2 do not have exact binary float representations, while Decimal supports exact decimal representation and configurable rounding.

Common alternatives include Decimal or integer minor units, such as cents. Neither choice defines the currency, permitted scale, input parsing, or rounding policy by itself; the application must specify those and keep the database representation consistent. Replacing float alone does not make a payment flow safe.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Bug 3: The balance check and updates can race

The endpoint reads the sender’s balance, checks it, and then updates two balances. If two requests run concurrently, both could read the same balance and both pass the check. Their combined transfers may then overdraw the sender.

Use a strategy appropriate to the database to make the check and both updates safe against competing requests. In PostgreSQL, row-level locking includes SELECT FOR UPDATE, which locks selected rows against competing updates until the transaction ends. This is one database-specific mechanism, not a universal prescription. When locking both accounts, the implementation must also consider consistent lock ordering and how it handles deadlocks.

A transaction wrapper by itself is not a guarantee: the safety of a read-check-write sequence depends on the database and isolation level, as well as the concrete locking or conflict-handling strategy.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What to take into the next review

  • Check that invalid amounts are rejected before any balance changes.
  • Look for a money representation and rounding policy that match the currency and storage layer.
  • Trace concurrent requests through the balance check and both account updates; verify how the chosen database strategy prevents conflicting transfers.

The original challenge and its three planted findings appeared in Anas Bahraoui’s DEV Community article, published October 2, 2026. It also describes ReviewIQ as a place to practice reviewing planted-bug examples. The article states that its first five reviews are free and do not require a card; those are the article’s offer terms, not independently verified current terms.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.