Centralize OAuth grant_type validation in SnowflakeHook#61969
Open
SameerMesiah97 wants to merge 1 commit intoapache:mainfrom
Open
Centralize OAuth grant_type validation in SnowflakeHook#61969SameerMesiah97 wants to merge 1 commit intoapache:mainfrom
SameerMesiah97 wants to merge 1 commit intoapache:mainfrom
Conversation
potiuk
approved these changes
Feb 15, 2026
Member
|
tests failing :( |
Contributor
Author
The failures seem unrelated to my changes. I see some network errors. I will force push again to re-trigger the CI workflow. |
Add _validate_grant_type and _SUPPORTED_GRANT_TYPES to centralize OAuth grant_type validation. Update _get_conn_params and _get_valid_oauth_token to delegate validation to the new method. Added a unit test covering supported, unsupported, and missing grant_type values.
a6925a3 to
82739a3
Compare
Contributor
Author
CI is green now. It was a flake. |
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
This change centralizes OAuth
grant_typevalidation inSnowflakeHookby introducing a_validate_grant_typemethod and aSUPPORTED_GRANT_TYPESconstant.Validation logic that was previously implemented inline in
_get_conn_paramsand_get_valid_oauth_tokennow delegates to_validate_grant_type, providing a single validation entry point for supported OAuth grant types.Rationale
grant_typevalidation was previously implemented in multiple locations within the hook. Consolidating this logic into a single validation method ensures consistent enforcement of supported values and reduces duplication across OAuth-related code paths. Validation is performed during OAuth resolution rather than during static connection parameter construction, preserving the separation between configuration parsing and authentication enforcement and avoiding impact on non-OAuth authentication flows such as Azure-based authentication. Error messages for invalid or missinggrant_typevalues have been consolidated under the new validation method.Notes
Removed the redundant inline
client_credentialsgrant type check in_get_valid_oauth_token.Tests
Added a parametrized unit test covering supported, unsupported, and missing
grant_typevalues to ensure centralized validation behaves consistently across valid and invalid inputs.Backwards Compatibility
Method signatures of public APIs have not been altered. No behavior changes have been introduced. Error messages for invalid or missing
grant_typevalues have been standardized as part of the centralized validation.