The guard condition was inverted: `if not deck_row:` entered the query block when no deck was found, causing `deck_row[0]` to crash with 'NoneType' object is not subscriptable. Flipped to `if deck_row:` so the query runs only when the deck exists.
The guard condition was inverted: `if not deck_row:` entered the query block when no deck was found, causing `deck_row[0]` to crash with 'NoneType' object is not subscriptable. Flipped to `if deck_row:` so the query runs only when the deck exists.