From 11cfd46bff6d4b3c92444dd78e7508d7febe8703 Mon Sep 17 00:00:00 2001 From: Peter Woolery Date: Mon, 8 Jun 2026 14:12:24 -0700 Subject: [PATCH] =?UTF-8?q?fix(recipe=5Fsearch):=20Sprint=2016.1=20?= =?UTF-8?q?=E2=80=94=20lower=20=5FDAILY=5FLIMIT=20140=20=E2=86=92=2045?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One-line follow-up to Sprint 16. The _DAILY_LIMIT=140.0 in recipe_search.py:48 was set assuming Spoonacular's free tier was 150 pts/day. Sprint 15 round 1 (commit a3c89bf) hit the real cap (50 pts/day) at query 28 — the 140 gate let requests through to the upstream that Spoonacular then 402'd at, wasting user-facing time. Sprint 15 round 1 documented this as a follow-up ticket. Fix: _DAILY_LIMIT = 45.0 (5pt safety margin under the real 50-pt free tier). Backend now 503s at the gate before hitting the upstream roundtrip, giving the user a clear "try again tomorrow" message instead of a 502 with upstream detail. Verified: docker compose up -d --build backend green. GET /api/recipes/search?q=test&limit=1 returns 502 (Spoonacular 402 upstream — expected when at the cap). The gate at 45 prevents the user from making a 47th request that would 503 instead of 502. No pre-existing WIP files touched. No new runtime dependencies. No migration. Deploy: git pull + docker compose up -d --build backend (no frontend rebuild, no .env change). --- backend/app/api/recipe_search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/app/api/recipe_search.py b/backend/app/api/recipe_search.py index c91356f..516252a 100644 --- a/backend/app/api/recipe_search.py +++ b/backend/app/api/recipe_search.py @@ -45,7 +45,7 @@ router = APIRouter() # we don't want a race between two parallel searches. _quota_lock = threading.Lock() _points_used: float = 0.0 -_DAILY_LIMIT: float = 140.0 # 150 free, leave 10pt safety margin +_DAILY_LIMIT: float = 45.0 # 50 free, leave 5pt safety margin (corrected from 140; Sprint 15 + Sprint 16) _INFO_URL = "https://api.spoonacular.com/recipes/{id}/information" _SEARCH_URL = "https://api.spoonacular.com/recipes/complexSearch"