Skip to content

v0.8.5 - Descriptive TEFAS errors + WAF retry

Choose a tag to compare

@saidsurucu saidsurucu released this 17 Apr 21:14
· 12 commits to master since this release

Bug Fixes

  • Descriptive TEFAS errors (closes #14): Fund(...).info no longer surfaces a bare JSONDecodeError when TEFAS returns an empty body or HTML maintenance page. Errors now include the HTTP status, content-type, and a body preview so failures are diagnosable at a glance.
  • Auto-retry for transient WAF blocks: TEFAS requests retry up to 3 times with exponential backoff (0.5s → 1s → 2s) when the response is empty, HTML, or malformed JSON. Happy paths pay no overhead.

Applied consistently across all 6 TEFAS JSON endpoints (GetAllFundAnalyzeData, BindHistoryInfo, BindHistoryAllocation, BindComparisonFundReturns, BindComparisonManagementFees).

Before

APIError: Failed to fetch fund detail for AFV: Expecting value: line 1 column 1 (char 0)

After

APIError: Failed to fetch fund detail for AFV: TEFAS GetAllFundAnalyzeData
returned an empty response (HTTP 200, content-type='text/html'). Upstream
API may be down or rate-limited.

Technical Changes

  • borsapy/_providers/tefas.py: new _safe_json() helper + _post_json() with retry
  • All 6 response.json() call sites consolidated to _post_json
  • 10 new unit tests in tests/test_tefas.py