No retry/backoff for transient network failures (violates MVP contract) #5

Closed
opened 2026-05-09 05:10:09 +00:00 by Mark · 0 comments
Owner

Severity: Medium

File: custom_components/yeedi/api.py (no retry logic present)

Issue: The MVP contract (mvp_contract.yaml quality_bars.reliability) explicitly requires:

"Transient network failures are retried with backoff."

However, the _request method in api.py has no retry logic. A single transient failure (DNS hiccup, temporary 5xx, connection reset) immediately raises YeediApiError which becomes UpdateFailed in the coordinator, marking the update as failed.

Fix: Add a retry wrapper with exponential backoff (e.g., using aiohttp_retry or a simple retry loop for 503/502/connection errors):

async def _request_with_retry(self, ...):
    for attempt in range(3):
        try:
            return await self._request(...)
        except (aiohttp.ClientError, asyncio.TimeoutError) as err:
            if attempt == 2:
                raise
            await asyncio.sleep(2 ** attempt)
**Severity:** Medium **File:** `custom_components/yeedi/api.py` (no retry logic present) **Issue:** The MVP contract (`mvp_contract.yaml` quality_bars.reliability) explicitly requires: > "Transient network failures are retried with backoff." However, the `_request` method in `api.py` has no retry logic. A single transient failure (DNS hiccup, temporary 5xx, connection reset) immediately raises `YeediApiError` which becomes `UpdateFailed` in the coordinator, marking the update as failed. **Fix:** Add a retry wrapper with exponential backoff (e.g., using `aiohttp_retry` or a simple retry loop for 503/502/connection errors): ```python async def _request_with_retry(self, ...): for attempt in range(3): try: return await self._request(...) except (aiohttp.ClientError, asyncio.TimeoutError) as err: if attempt == 2: raise await asyncio.sleep(2 ** attempt) ```
Mark closed this issue 2026-05-15 16:19:58 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Mark/yeedi_awmbuild#5
No description provided.