--- action.py	(original)
+++ action.py	(refactored)
@@ -816,7 +816,7 @@
                 current_shelves = []
             calibre_tags = self._get_calibre_tags_for_book(db, calibre_id, tag_column, tag_column_label, is_multiple)
             for calibre_tag in calibre_tags:
-                for shelf_name, mapped_tag_values in tag_mappings.items():
+                for shelf_name, mapped_tag_values in list(tag_mappings.items()):
                     if calibre_tag not in mapped_tag_values:
                         continue
                     if len(mapped_tag_values) > 1:
