♻️ Rely on the client's auto-reauth instead of coordinator-level re-auth #39
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "coordinator-client-auto-reauth"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The coordinator predates the client's
auto_reauth: it detects credential failures by string-matching"401"/"403"in exception messages (internal_AuthError) and re-authenticates + retries the whole fetch on any exception. Since comwatt-client 0.3.x the client re-authenticates expired sessions itself, and since 0.3.4ComwattAuthErrorreliably means credentials rejected (401/403) or session invalid.The broad per-device
except Exceptionblocks also swallowed aComwattAuthError(password changed mid-cycle → entities silentlyNonefor a cycle instead of triggering the reauth flow).Change
_AuthError, the string matching, and the re-auth + retry block — the client owns session recovery now_async_update_data:ComwattAuthError→ConfigEntryAuthFailed(reauth flow), anything else →UpdateFailed(retry next cycle)authenticate()inlined in_fetch_all(still needed once so the client can auto-reauth later)ComwattAuthErrorinstead of swallowing itNet: -12 lines in the coordinator, no more message parsing.
Tests
test_setup_starts_reauth_on_bad_credentials: 401 →SETUP_ERROR+ reauth flow startedtest_auth_error_mid_fetch_is_not_swallowed: auth error from a device fetch propagates (no silentNonedata) andauthenticate.call_count == 1proves no coordinator-level re-authtest_setup_retry_on_transient_network_errorunchanged (generic errors still →SETUP_RETRY)Depends on comwatt-client 0.3.4 (#37, merged). Independent of #38 (config_flow).
WIP: ♻️ Rely on the client's auto-reauth instead of coordinator-level re-authto ♻️ Rely on the client's auto-reauth instead of coordinator-level re-auth