Skip to content

Conversation

@dmcgill50
Copy link

Problem

The library currently crashes when calling store.get_menu() with this error:

Exception: PRODUCT NOT FOUND: 9413 CouponPizza

This affects many users as evidenced by issues #115, #125, #119, and others.

Root Cause

The Domino's API sometimes references product codes in the Categorization section that don't exist in the Products, Coupons, or PreconfiguredProducts dictionaries. These are phantom references to items that may be:

  • Excluded from the current store
  • Unsupported in certain regions
  • Temporarily unavailable
  • No longer offered

Solution

Changed pizzapi/menu.py line 66 to gracefully skip missing products instead of raising an exception:

# Before
if product_code not in self.menu_by_code:
    raise Exception('PRODUCT NOT FOUND: %s %s' % (product_code, category.code))

# After  
if product_code not in self.menu_by_code:
    # Skip products that don't exist in the menu data
    # This handles phantom references and excluded/unavailable items
    continue

Testing

Tested with multiple Domino's stores that previously failed:

✅ Menu objects now create successfully
✅ Order objects can be instantiated
✅ Items can be added to orders
✅ The library is functional end-to-end

Example test:

from pizzapi import Address, Customer, Order, Store

address = Address('700 Pennsylvania Avenue', 'Washington', 'DC', '20408')
store = address.closest_store()

# This now works (previously crashed)
customer = Customer('Test', 'User', 'test@example.com', '5555555555')
order = Order(store, customer, address)
order.add_item('12SCREEN')  # Medium Hand Tossed Pizza

Impact

Why This Approach

This is the safest fix because:

  1. Graceful degradation - Menu loads with available items only
  2. No side effects - Missing items simply aren't included in categories
  3. Maintains functionality - All other menu operations work normally
  4. Future-proof - Handles API changes without crashing

Alternative approaches would require:

  • Parsing Variants into menu_by_code (larger refactor)
  • Checking ExcludedProducts everywhere (more complex)
  • Hardcoding exceptions (not maintainable)

Related Issues

Closes #115
Closes #125
Closes #119

May also fix #122, #69, and #59 which report similar menu loading issues.

…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 ggrammar#115, ggrammar#125, ggrammar#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants