fix: surface Spotify quota exhaustion
Some checks are pending
ci / backend (push) Waiting to run
ci / frontend (push) Waiting to run

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Justin Visser 2026-08-11 22:07:06 +02:00
parent 358d058392
commit bfea9efb5e
6 changed files with 97 additions and 10 deletions

View file

@ -146,6 +146,30 @@ def test_intent_stage_failures_yield_one_typed_error_event() -> None:
asyncio.run(run())
def test_grounding_quota_yields_typed_error_instead_of_empty_results() -> None:
class QuotaCatalog(FakeCatalog):
"""Exhaust the Spotify quota on the first grounding search."""
async def search_tracks(self, query: str, limit: int = 10) -> list[Track]:
self.search_call_count += 1
raise SpotifyQuotaExhaustedError(0.0, "QUOTA_EXCEEDED")
async def run() -> None:
track = _track("candidate", "Candidate Song")
catalog = QuotaCatalog(())
recommender = FakeRecommender([_intent(track)])
events = await _run_pipeline(catalog, recommender)
assert [event.type for event in events] == ["metadata", "error"]
assert isinstance(events[-1], PipelineErrorEvent)
assert events[-1].code == "quota_exhausted"
assert catalog.search_call_count == 1
assert recommender.rerank_call_count == 0
asyncio.run(run())
def test_taste_failure_cancels_sibling_fetches() -> None:
class FailingTasteCatalog(FakeCatalog):
"""Fail one taste request after all sibling requests have started."""