mutated × unstructured — blows up live on input you didn't expect

Divide-by-Zero from an Empty Aggregate

An average over input that can be empty drives the denominator to zero.

01the recipe

In the wild

example.py
# SMELL: average a list that can be empty; the denominator reaches zero.
# (var/let/mut x divide by zero)
total = sum(values)
count = len(values)            # 0 when the input is empty
avg = total / count            # ZeroDivisionError, first seen on real data

# RIGHT: guard the exceptional input before you divide.
avg = total / count if count else 0.0
A mutable count fed straight into a division blows up the moment the input is empty -- a case dev data never had. The crash reads as a divide-by-zero, but the root is the unchecked exceptional condition.
// observed
bug:   ZeroDivisionError: division by zero on an empty list
right: empty input yields 0.0, not a 500
02weakness catalog

Mapped weaknesses (CWE)

On its own, this defect is catalogued by MITRE as one or more of these weaknesses. The exploitable vulnerability usually appears only when it chains or combines with another.