From 6c309b1e629e73f8a8ac8239d739b890c6fca437 Mon Sep 17 00:00:00 2001 From: TPV Date: Tue, 4 Aug 2026 11:49:19 -0700 Subject: [PATCH] use .get for has_msrp --- src/monitor_utils/runner.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/monitor_utils/runner.py b/src/monitor_utils/runner.py index 2933fea..bc689d4 100644 --- a/src/monitor_utils/runner.py +++ b/src/monitor_utils/runner.py @@ -169,7 +169,11 @@ def build_product_details( original_price = product["originalPrice"] percentage = 0 - has_msrp = product["hasMsrp"] + # Defaulted, not indexed: documents written before the field existed have no + # hasMsrp at all, and stale ones that drop out of a monitor's feed are never + # re-upserted, so they would KeyError here forever. True keeps them on the + # pre-existing threshold path rather than silently routing them as MSRP-less. + has_msrp = product.get("hasMsrp", True) if has_msrp: if not original_price: LOGGER.warning( @@ -218,7 +222,7 @@ def build_product_details( original_price=original_price, price_before_drop=product["priceBeforeDrop"], edu_price=product["eduPrice"], - past_prices=product["pastPrices"], + past_prices=product.get("pastPrices"), has_msrp=has_msrp, ), availability=AvailabilityInfo( -- 2.54.0