Skip to content

Fix provider fallback circuit on symbol-scoped errors#12

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-8ac3
Draft

Fix provider fallback circuit on symbol-scoped errors#12
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-8ac3

Conversation

@cursor

@cursor cursor Bot commented Jun 9, 2026

Copy link
Copy Markdown

Bug and impact

Repeated per-symbol fallback HTTP errors (for example Polygon 404 or CMC 400 for unknown symbols) were counted as provider-wide circuit failures. During a scan/backtest, a handful of bad symbols could open the shared fallback circuit and silently skip Polygon/CMC OHLCV requests for unrelated later symbols, causing missed qualifications or incomplete backtest/snapshot data.

Root cause

PriceHistoryFallbackClient._polygon_http_get and _cmc_http_get recorded every non-200 response as a circuit failure after retries. The circuit is shared by the fallback client, so symbol/request validation errors accumulated globally.

Fix

Only record circuit failures for provider-wide conditions: timeouts/exceptions, 408, exhausted 429, auth/global access failures, and 5xx responses. Symbol-scoped 4xx responses continue to return to callers without opening the provider circuit.

Validation

  • python3 -m pytest tests/test_price_history_fallback_circuit.py tests/test_provider_rate_limit.py
  • python3 -m py_compile api/price_history_fallback.py utils/provider_circuit.py
Open in Web View Automation 

Co-authored-by: Edward Thompson <edwardlthompson@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant