Bug: Generator exhaustion in SpendingByCategory reducer yields 0 instead of total

Author: cynicalmindsetCreated Sep 28, 2026Updated Sep 28, 2026

Expected Behavior

In solutions/system_design/mint/mint_mapreduce.py, the SpendingByCategory.reducer() method should yield the calculated sum of amounts (total) for each (period, category) key.

Actual Behavior

In reducer(self, key, values):

python
total = sum(values)
self.handle_budget_notifications(key, total)
yield key, sum(values)  # <-- BUG: values generator is already exhausted

Source: donnemartin/system-design-primer