Skip to content

Mark network errors as retriable in authentication methods#61

Merged
eman merged 1 commit intomainfrom
fix/mark-network-errors-as-retriable
Jan 16, 2026
Merged

Mark network errors as retriable in authentication methods#61
eman merged 1 commit intomainfrom
fix/mark-network-errors-as-retriable

Conversation

@eman
Copy link
Copy Markdown
Owner

@eman eman commented Jan 16, 2026

This change addresses an issue where network errors during authentication were being treated the same as invalid credentials, causing unnecessary reauth prompts when Home Assistant starts without network connectivity.

Changes:

  • Mark network errors in sign_in() as retriable
  • Mark network errors in refresh_token() as retriable
  • This allows consuming code (e.g. Home Assistant integration) to distinguish between transient network failures and actual auth failures

The retriable flag is set via the existing Nwp500Error.retriable attribute which was designed for this exact purpose.

Fixes: Network errors during startup cause false reauth requests

This change addresses an issue where network errors during authentication
were being treated the same as invalid credentials, causing unnecessary
reauth prompts when Home Assistant starts without network connectivity.

Changes:
- Mark network errors in sign_in() as retriable
- Mark network errors in refresh_token() as retriable
- This allows consuming code (e.g. Home Assistant integration) to distinguish
  between transient network failures and actual auth failures

The retriable flag is set via the existing Nwp500Error.retriable attribute
which was designed for this exact purpose.

Fixes: Network errors during startup cause false reauth requests
@eman eman requested a review from Copilot January 16, 2026 00:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves error handling in the authentication module by distinguishing between transient network failures and permanent authentication failures. When network errors occur during sign-in or token refresh operations, they are now marked as retriable, allowing consuming code (like the Home Assistant integration) to avoid triggering unnecessary re-authentication prompts when the network is temporarily unavailable.

Changes:

  • Mark aiohttp.ClientError exceptions as retriable in sign_in() method
  • Mark aiohttp.ClientError exceptions as retriable in refresh_token() method

@eman eman merged commit 095e446 into main Jan 16, 2026
7 checks passed
@eman eman deleted the fix/mark-network-errors-as-retriable branch January 16, 2026 01:00
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.

2 participants