Skip to content

Add retry logic for OAuth token requests in SnowflakeHook#61796

Merged
potiuk merged 1 commit intoapache:mainfrom
SameerMesiah97:SFHook-Token-Request-Retries
Feb 15, 2026
Merged

Add retry logic for OAuth token requests in SnowflakeHook#61796
potiuk merged 1 commit intoapache:mainfrom
SameerMesiah97:SFHook-Token-Request-Retries

Conversation

@SameerMesiah97
Copy link
Contributor

@SameerMesiah97 SameerMesiah97 commented Feb 12, 2026

Description

Introduced retry logic for OAuth token requests in SnowflakeHook. The HTTP call was extracted into _request_oauth_token, and retry handling was added using tenacity, with retry classification implemented in _is_retryable_oauth_error. Retry applies only to connection/timeout errors and HTTP 5xx responses.

_get_valid_oauth_token now delegates access token requests to _request_oauth_token, which performs the HTTP call with retry behavior. Fail-fast semantics are preserved for non-retryable errors (e.g., HTTP 4xx).

Rationale

OAuth token requests can fail due to transient network issues or temporary upstream server errors. Retrying connection errors, timeouts, and HTTP 5xx responses improves robustness without masking configuration or credential issues, which continue to fail immediately.

Tests

Added unit tests that:

  • Verify retries on connection errors and HTTP 5xx responses.
  • Ensure HTTP 4xx errors do not trigger retries.
  • Ensure retries are capped at three attempts and that ConnectionError is propagated when retries are exhausted.

Documentation

Updated the get_oauth_token docstring to clarify that it may retry on transient failures during token acquisition.

Notes

  • Retry uses exponential backoff with a fixed maximum number of attempts.
  • Retry logic applies only to OAuth token acquisition.

Backwards Compatibility

Method signatures of public APIs have not been altered. The public API get_oauth_token now retries on retryable errors via _get_valid_oauth_token and _request_oauth_token.

@boring-cyborg boring-cyborg bot added area:providers provider:snowflake Issues related to Snowflake provider labels Feb 12, 2026
@SameerMesiah97 SameerMesiah97 force-pushed the SFHook-Token-Request-Retries branch 2 times, most recently from f1fed18 to dbaae98 Compare February 13, 2026 16:39
Introduced retry handling for OAuth token acquisition in SnowflakeHook using tenacity. Extracted the HTTP call into _request_oauth_token and added retry classification via _is_retryable_oauth_error. Retries apply only to connection errors and HTTP 5xx responses, while HTTP 4xx errors fail fast.

Updated unit tests to cover retry behavior, non-retryable errors, and retry exhaustion. Updated the get_oauth_token docstring to reflect retry semantics.
@SameerMesiah97 SameerMesiah97 force-pushed the SFHook-Token-Request-Retries branch from dbaae98 to 285ebd5 Compare February 13, 2026 20:24
Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

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

Nice!

@potiuk potiuk merged commit 203c044 into apache:main Feb 15, 2026
90 checks passed
choo121600 pushed a commit to choo121600/airflow that referenced this pull request Feb 22, 2026
Introduced retry handling for OAuth token acquisition in SnowflakeHook using tenacity. Extracted the HTTP call into _request_oauth_token and added retry classification via _is_retryable_oauth_error. Retries apply only to connection errors and HTTP 5xx responses, while HTTP 4xx errors fail fast.

Updated unit tests to cover retry behavior, non-retryable errors, and retry exhaustion. Updated the get_oauth_token docstring to reflect retry semantics.

Co-authored-by: Sameer Mesiah <smesiah971@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:snowflake Issues related to Snowflake provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants