Skip to content

Commit 9d79887

Browse files
committed
fix: propagate archive source transport errors
Transport and API failures from Archive.org and Wikimedia now reach corpus_builder while per-item Archive.org hydration remains tolerant. Update regression expectations for the corrected contract. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 08e2151 commit 9d79887

3 files changed

Lines changed: 13 additions & 24 deletions

File tree

‎tests/tools/test_stock_source_adapters.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ def test_unsplash_helpers_preserve_query_params():
109109
# defects rather than encoded as expected behavior. `strict=True` means
110110
# the suite fails the moment one of them is fixed and left in this map.
111111
_STILL_SWALLOWS_TRANSPORT_ERRORS = {
112-
"archive_org": "#511 follow-up: query cascade continues past a failed strategy",
113-
"wikimedia": "#511 follow-up: query cascade continues past a failed strategy",
114112
"pond5_pd": "#511 follow-up: API failure falls through to the web fallback",
115113
}
116114

‎tools/video/stock_sources/archive_org.py‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,9 @@ def search(self, query: str, filters: SearchFilters) -> list[Candidate]:
157157
("output", "json"),
158158
]
159159

160-
try:
161-
r = requests.get(_SEARCH_URL, params=params, timeout=30)
162-
r.raise_for_status()
163-
data = r.json()
164-
except Exception:
165-
# One strategy's network/parse error shouldn't kill the
166-
# whole cascade — try the next one.
167-
continue
160+
r = requests.get(_SEARCH_URL, params=params, timeout=30)
161+
r.raise_for_status()
162+
data = r.json()
168163
docs = (data.get("response") or {}).get("docs", []) or []
169164
if not docs:
170165
continue
@@ -328,9 +323,8 @@ def _hydrate_candidate(
328323
meta = r.json()
329324
except Exception:
330325
# Swallow per-item fetch failures — one bad item shouldn't
331-
# poison the whole search. Alternative would be to raise and
332-
# have corpus_builder catch per-source, but at this layer we
333-
# can keep going.
326+
# poison the whole search. Search-level failures above still
327+
# propagate so corpus_builder can report a broken source.
334328
return None
335329

336330
files = meta.get("files") or []

‎tools/video/stock_sources/wikimedia.py‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,14 @@ def search(self, query: str, filters: SearchFilters) -> list[Candidate]:
8282
"inprop": "url",
8383
}
8484

85-
try:
86-
r = requests.get(
87-
_API_URL,
88-
params=params,
89-
headers={"User-Agent": _USER_AGENT},
90-
timeout=30,
91-
)
92-
r.raise_for_status()
93-
data = r.json()
94-
except Exception:
95-
continue
85+
r = requests.get(
86+
_API_URL,
87+
params=params,
88+
headers={"User-Agent": _USER_AGENT},
89+
timeout=30,
90+
)
91+
r.raise_for_status()
92+
data = r.json()
9693
pages = list(((data.get("query") or {}).get("pages") or {}).values())
9794
if not pages:
9895
continue

0 commit comments

Comments
 (0)