diff --git a/backend/app/routes/search.py b/backend/app/routes/search.py index c0e3d012..75131d2e 100644 --- a/backend/app/routes/search.py +++ b/backend/app/routes/search.py @@ -268,7 +268,11 @@ def search_youtube( except (YouTubeError, search_scrape.ScrapeError) as exc: if collected: break # keep what we already gathered - raise HTTPException(status_code=502, detail=f"YouTube search failed: {exc}") + # 422, not 502: this is a JSON endpoint, and the FE treats 502/503/504 as a gateway + # dropout (auto-retry + "connection lost" banner — lib/api/core RETRIABLE_GATEWAY), + # which hides the real message and burns a second quota-costed search. Upstream failure + # on a JSON endpoint = 422 + message; reserve 5xx for the raw byte-proxies. (B-core-1) + raise HTTPException(status_code=422, detail=f"YouTube search failed: {exc}") from exc # Drop currently-live/upcoming, channel-less, and blocked-channel results. candidates = [