From da382942d394186cd81d1b7a891858cd6548316f Mon Sep 17 00:00:00 2001 From: C <0xicl33n@gmail.com> Date: Sun, 4 Jan 2026 12:30:59 -0800 Subject: [PATCH] very confusing lol --- src/asquare.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/asquare.py b/src/asquare.py index f1060d0..fc805d5 100644 --- a/src/asquare.py +++ b/src/asquare.py @@ -234,13 +234,15 @@ async def update_itm(item_id: str, lego_set: dict, item_data: dict = None): # Convert price to cents for Square API price_in_cents = int(set_adjustedprice * 100) - # Get current item to retrieve variation ID (only if not provided) - if item_data is None: - item = await get_item_by_id(item_id) - else: - item = item_data + # ALWAYS fetch fresh item data right before update to get latest version + # The item_data parameter is just used to avoid lookup during enrichment check, + # but we need fresh data for the update to avoid version conflicts + print( + f"[@DEBUG] Fetching fresh item data before update to get current version..." + ) + fresh_item = await get_item_by_id(item_id) - variations = item.get("variations", []) + variations = fresh_item.get("variations", []) if not variations: print( @@ -253,11 +255,10 @@ async def update_itm(item_id: str, lego_set: dict, item_data: dict = None): variation_version = variations[0].get("version") # Get current version for version control - current_version = item.get("version") + current_version = fresh_item.get("version") - print(f"[@DEBUG] Item version: {current_version}") - print(f"[@DEBUG] Variation version: {variation_version}") - print(f"[@DEBUG] Full item data: {json.dumps(item, indent=2)}") + print(f"[@DEBUG] Fresh item version: {current_version}") + print(f"[@DEBUG] Fresh variation version: {variation_version}") # Build upsert body upsert_body = {