Skip to content

Retry transport-level failures during OAuth2 token refresh#2

Merged
hexmode merged 1 commit into
mainfrom
fix/token-refresh-transport-retry
Jul 15, 2026
Merged

Retry transport-level failures during OAuth2 token refresh#2
hexmode merged 1 commit into
mainfrom
fix/token-refresh-transport-retry

Conversation

@hexmode

@hexmode hexmode commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

What & why

Only _send retried transport-level failures (RemoteDisconnected, timeouts, reset connections); the OAuth2 token POST in _refresh_token did not. So a transient network blip during token refresh would raise straight out and abort the caller's run — even though the same blip during a normal request is transparently retried.

This extracts the transport-retry logic into a _request_with_transport_retry helper and uses it for both _send and the token POST in _refresh_token. Behavior for _send is unchanged (same 5-attempt backoff); the token refresh now gets the same resilience.

Changes

  • Add _request_with_transport_retry(method, url, **kwargs) (5 attempts, 5s×attempt backoff, raises HelpScoutError if all fail).
  • _refresh_token and _send both route their request through it.
  • Bump version 1.0.3 → 1.0.4 (drop if you'd rather bump at release).

Tests

Added test_token_refresh_retries_transport_error (mirrors the existing responses-based tests): a transport-level failure on the token POST is retried and the client still initializes. pytest — all 10 pass.

Note: this is the fix currently carried in-tree in the devops-fabric consumer; upstreaming it so the published package matches.

Extract the transport-retry logic (RemoteDisconnected, timeouts, reset
connections) into a _request_with_transport_retry helper and use it for both
_send and the OAuth2 token POST in _refresh_token. Previously only _send retried
transport failures, so a transient network error during token refresh would
abort the client. Bump to 1.0.4; add a test that the token POST is retried.
@hexmode hexmode self-assigned this Jul 15, 2026
@hexmode
hexmode merged commit 86f7b42 into main Jul 15, 2026
5 checks passed
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.

1 participant