v0.8.5 - Descriptive TEFAS errors + WAF retry
Bug Fixes
- Descriptive TEFAS errors (closes #14):
Fund(...).infono longer surfaces a bareJSONDecodeErrorwhen 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