The fix was one line.

if not items: return []

Enter fullscreen mode

Exit fullscreen mode

That's it Three words a colon and a pair of brackets It took me 10 seconds to type. 10 minutes to test and verify 10 seconds to deploy.