Bug
Several provider functions call rate_limit_wait() but skip the is_circuit_open() check, wasting work when a provider is known-broken:
identify_book_from_transcript() (openrouter.py ~line 223) — waits 5s then calls a circuit-broken provider
detect_audio_language() (gemini.py ~line 336) — extracts audio sample + base64 encodes before discovering Gemini is circuit-broken
lookup_audnexus_by_asin() (audnexus.py ~line 153) — calls record_api_success() BEFORE checking the HTTP status code, incorrectly resetting the circuit breaker on 500s
Fix
- Add
if is_circuit_open('openrouter'): return None at the top of identify_book_from_transcript()
- Add
if is_circuit_open('gemini'): return None before the audio extraction in detect_audio_language()
- Move
record_api_success('audnexus') after the response.status_code == 200 check in lookup_audnexus_by_asin()
Severity
Low — not a spam risk (rate limiters still apply) but wastes CPU/disk on audio extraction and makes circuit breakers less effective.
Found via code audit.
Bug
Several provider functions call
rate_limit_wait()but skip theis_circuit_open()check, wasting work when a provider is known-broken:identify_book_from_transcript()(openrouter.py ~line 223) — waits 5s then calls a circuit-broken providerdetect_audio_language()(gemini.py ~line 336) — extracts audio sample + base64 encodes before discovering Gemini is circuit-brokenlookup_audnexus_by_asin()(audnexus.py ~line 153) — callsrecord_api_success()BEFORE checking the HTTP status code, incorrectly resetting the circuit breaker on 500sFix
if is_circuit_open('openrouter'): return Noneat the top ofidentify_book_from_transcript()if is_circuit_open('gemini'): return Nonebefore the audio extraction indetect_audio_language()record_api_success('audnexus')after theresponse.status_code == 200check inlookup_audnexus_by_asin()Severity
Low — not a spam risk (rate limiters still apply) but wastes CPU/disk on audio extraction and makes circuit breakers less effective.
Found via code audit.