From b2a0b59cbed4c289c2704b764471b0c91cd5b80d Mon Sep 17 00:00:00 2001 From: robviren Date: Thu, 23 Jul 2026 19:24:01 -0500 Subject: [PATCH] Moxfield import fix --- worker.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/worker.py b/worker.py index 7c4d78f..09508a4 100644 --- a/worker.py +++ b/worker.py @@ -53,8 +53,15 @@ async def resolve_card( if scry_id: url = f"https://api.scryfall.com/cards/{quote(scry_id)}" r = await _scryfall_get(client, url, slug) - r.raise_for_status() - return r.json() + if r.status_code == 200: + return r.json() + if r.status_code != 404 or not name: + r.raise_for_status() + # Moxfield's scryfall_id can go stale (Scryfall periodically deletes/merges + # card ids when it corrects duplicate prints, e.g. basic lands and + # guildgates with many near-identical art variations). Fall back to a + # name lookup rather than failing the whole card. + db.add_log(slug, f" scryfall_id {scry_id} is stale (404) — falling back to name lookup") if scry_url: parsed = parse_scry_url(scry_url)