Add retry logic for OAuth token requests in SnowflakeHook#61796
Merged
potiuk merged 1 commit intoapache:mainfrom Feb 15, 2026
Merged
Add retry logic for OAuth token requests in SnowflakeHook#61796potiuk merged 1 commit intoapache:mainfrom
potiuk merged 1 commit intoapache:mainfrom
Conversation
f1fed18 to
dbaae98
Compare
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.
dbaae98 to
285ebd5
Compare
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Introduced retry logic for OAuth token requests in
SnowflakeHook. The HTTP call was extracted into_request_oauth_token, and retry handling was added usingtenacity, with retry classification implemented in_is_retryable_oauth_error. Retry applies only to connection/timeout errors and HTTP 5xx responses._get_valid_oauth_tokennow 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:
ConnectionErroris propagated when retries are exhausted.Documentation
Updated the
get_oauth_tokendocstring to clarify that it may retry on transient failures during token acquisition.Notes
Backwards Compatibility
Method signatures of public APIs have not been altered. The public API
get_oauth_tokennow retries on retryable errors via_get_valid_oauth_tokenand_request_oauth_token.