From 8dc90eadb70ac206dee0aa59f42294c4c484964a Mon Sep 17 00:00:00 2001 From: David McGill Date: Wed, 8 Oct 2025 05:38:49 -0500 Subject: [PATCH] Fix: Skip missing products in menu categorization instead of raising exception The Domino's API sometimes references product codes in the Categorization section that don't exist in Products, Coupons, or PreconfiguredProducts. This causes Menu object creation to fail with "PRODUCT NOT FOUND" errors. Root Cause: - Categorization lists products by code (e.g., "9413") - These codes don't always exist in the parsed menu items - They may be phantom references, excluded items, or unsupported products Solution: Changed line 66 in build_categories() from raising an exception to gracefully skipping missing products with 'continue'. This allows the menu to load successfully while only including valid, available products. Impact: - Fixes issues #115, #125, #119, and other "PRODUCT NOT FOUND" errors - Enables Menu and Order objects to be created successfully - Maintains backward compatibility - No breaking changes to the API Tested: - Successfully creates Menu objects that previously failed - Order creation works with the patched library - Items can be added to orders and placed --- pizzapi/menu.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pizzapi/menu.py b/pizzapi/menu.py index 9a0718b..c695ba5 100755 --- a/pizzapi/menu.py +++ b/pizzapi/menu.py @@ -63,7 +63,9 @@ def build_categories(self, category_data, parent=None): category.subcategories.append(new_subcategory) for product_code in category_data['Products']: if product_code not in self.menu_by_code: - raise Exception('PRODUCT NOT FOUND: %s %s' % (product_code, category.code)) + # Skip products that don't exist in the menu data + # This handles phantom references and excluded/unavailable items + continue product = self.menu_by_code[product_code] category.products.append(product) product.categories.append(category)