diff --git a/src/asquare.py b/src/asquare.py index f649c18..126c0a6 100644 --- a/src/asquare.py +++ b/src/asquare.py @@ -272,25 +272,22 @@ async def update_itm(item_id: str, lego_set: dict, item_data: dict = None): # Get current version for version control current_version = fresh_item.get("version") - # batch_get doesn't return category_id, so use original item_data if available + # CRITICAL: batch_get NEVER returns category_id (always None) + # We MUST use the category from initial item_data (from search which includes category) + # or fallback to LEGO_CAT_ID since we know this is a LEGO item if item_data and item_data.get("category_id"): category_id = item_data.get("category_id") print(f"[@DEBUG] Using category_id from item_data: {category_id}") else: - category_id = fresh_item.get("category_id") or LEGO_CAT_ID + # Fallback to LEGO_CAT_ID (we know it's a LEGO item if enrichment was triggered) + category_id = LEGO_CAT_ID print( - f"[@DEBUG] Category ID from fresh_item: {fresh_item.get('category_id')}" + f"[@WARNING] No category_id in item_data, using LEGO_CAT_ID: {LEGO_CAT_ID}" ) - if not fresh_item.get("category_id"): - print( - f"[@WARNING] No category_id in fresh_item, using LEGO_CAT_ID: {LEGO_CAT_ID}" - ) print(f"[@DEBUG] Fresh item version: {current_version}") print(f"[@DEBUG] Fresh variation version: {variation_version}") - print(f"[@DEBUG] Final category_id: {category_id}") - print(f"[@DEBUG] Present at all locations: {present_at_all_locations}") - print(f"[@DEBUG] Present at locations: {present_at_location_ids}") + print(f"[@DEBUG] Final category_id for upsert: {category_id}") # Build upsert body variation_obj = {