diff --git a/crawlers/oshwhub/crawler.py b/crawlers/oshwhub/crawler.py index f416d84..9e87a64 100644 --- a/crawlers/oshwhub/crawler.py +++ b/crawlers/oshwhub/crawler.py @@ -758,7 +758,14 @@ def _fetch_pro_legacy( doc_metas: list[dict] = [] # 2. schematic containers -> sheet UUIDs via /api/schematic/lists - sch_container_uuids = [b["sch"] for b in boards if b.get("sch")] + # Filter `boards[].sch` against `ticket.schematics` keys: a board may + # reference a deprecated/deleted sch (e.g. "主控板V1(废弃)") whose + # UUID is gone from the schematics dict. Asking schematic/lists for it + # returns 401 and aborts the whole batch. Skip it. + valid_sch_uuids = set((manifest_ticket.get("schematics") or {}).keys()) + sch_container_uuids = [ + b["sch"] for b in boards if b.get("sch") and b["sch"] in valid_sch_uuids + ] sheet_uuids: list[str] = [] if sch_container_uuids: containers = _pro_post_json( @@ -798,7 +805,11 @@ def _fetch_pro_legacy( time.sleep(sleep) # 4. PCB documents via documents/lists docType=3 - pcb_uuids = [b["pcb"] for b in boards if b.get("pcb")] + # Same deprecated-uuid risk as #2 — filter against ticket.pcbs keys. + valid_pcb_uuids = set((manifest_ticket.get("pcbs") or {}).keys()) + pcb_uuids = [ + b["pcb"] for b in boards if b.get("pcb") and b["pcb"] in valid_pcb_uuids + ] if pcb_uuids: pcbs = _pro_post_json( pro_client,