Skip to content

Centralize OAuth grant_type validation in SnowflakeHook#61969

Open
SameerMesiah97 wants to merge 1 commit intoapache:mainfrom
SameerMesiah97:SFHook-Centralize-Grant-Type-Validation
Open

Centralize OAuth grant_type validation in SnowflakeHook#61969
SameerMesiah97 wants to merge 1 commit intoapache:mainfrom
SameerMesiah97:SFHook-Centralize-Grant-Type-Validation

Conversation

@SameerMesiah97
Copy link
Contributor

Description

This change centralizes OAuth grant_type validation in SnowflakeHook by introducing a _validate_grant_type method and a SUPPORTED_GRANT_TYPES constant.

Validation logic that was previously implemented inline in _get_conn_params and _get_valid_oauth_token now delegates to _validate_grant_type, providing a single validation entry point for supported OAuth grant types.

Rationale

grant_type validation 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 missing grant_type values have been consolidated under the new validation method.

Notes

Removed the redundant inline client_credentials grant type check in _get_valid_oauth_token.

Tests

Added a parametrized unit test covering supported, unsupported, and missing grant_type values 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_type values have been standardized as part of the centralized validation.

@boring-cyborg boring-cyborg bot added area:providers provider:snowflake Issues related to Snowflake provider labels Feb 15, 2026
@potiuk
Copy link
Member

potiuk commented Feb 15, 2026

tests failing :(

@SameerMesiah97
Copy link
Contributor Author

tests failing :(

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.
@SameerMesiah97 SameerMesiah97 force-pushed the SFHook-Centralize-Grant-Type-Validation branch from a6925a3 to 82739a3 Compare February 15, 2026 22:43
@SameerMesiah97
Copy link
Contributor Author

tests failing :(

CI is green now. It was a flake.

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