Finding the edge case that crashes the system.
Correctness bugs aren't syntax errors; the code runs, but it does the wrong thing under specific conditions. To spot them in a Code Review, you must aggressively read for the Edge Cases: what happens if the input is empty? What if it's negative? What if it hits the exact boundary condition?
A classic example is the Off-By-One Error. Using `<` instead of `<=` works perfectly for 99% of inputs, but fails exactly on the boundary, causing data loss or crashes.
def paginate(items, page_size):
if not items:
return []
pages = []
for i in range(0, len(items), page_size):
chunk = items[i : i + page_size]
pages.append(chunk)
if len(pages) > 5:
raise Exception("Too many pages!")
return pages
# The Bug: The developer wanted a maximum of 5 pages.
# So max items should be 10 (since page_size=2).
# If len(pages) is exactly 5 (input=10), it passes.
# If len(pages) is 6 (input=11), it raises an Exception.
# Is this correct? What if the input is 10 items?
# pages will have length 5. 5 > 5 is False. It passes.
# But what if the input is 11 items?
# pages will have length 6. 6 > 5 is True. Exception!
# The bug is a boundary requirement violation depending
# on how "maximum" was defined by product!