Skip to content

Handle HTTP 422 responses bypass to _process_response instead of raising immediately in Snowflake SQL API hook.#60891

Merged
shahar1 merged 6 commits into
apache:mainfrom
HyunWooZZ:snowflake/status_422_result
Feb 10, 2026
Merged

Handle HTTP 422 responses bypass to _process_response instead of raising immediately in Snowflake SQL API hook.#60891
shahar1 merged 6 commits into
apache:mainfrom
HyunWooZZ:snowflake/status_422_result

Conversation

@HyunWooZZ

Copy link
Copy Markdown
Contributor

Summary

This PR adjusts the error-handling behavior of SnowflakeSqlApiHook so that HTTP 422 responses are not raised immediately by raise_for_status(), but instead passed through to _process_response() for Snowflake-specific error parsing.
(We already implemented message parsing method, but we haven't leveraged.)

Snowflake SQL API uses 422 (Unprocessable Entity) to return rich, structured error payloads (e.g. STATEMENT_ERROR, STATEMENT_NOT_FOUND, Compile Error).
Raising early discards this payload and prevents the hook from providing meaningful error context to users.

related: #60765

Details

  • Snowflake SQL API returns HTTP 422 with structured error payloads for statement-level failures.
    Previously, raise_for_status() was called unconditionally, causing 422 responses to raise early and skip _process_response().

This PR updates the request flow:

  1. raise_for_status() is called for status >= 400 except 422
  2. 422 responses are passed through with their response body intact for Snowflake-specific parsing.

Applies the same behavior to both sync and async API calls.

Tests

  • Added tests to verify that HTTP 422 does not call raise_for_status() and returns (status, body) for:

    • synchronous requests
    • asynchronous requests
  • Added tests to confirm that HTTP 500 still raises and does not return a response body.

  • Refactored test helpers to make mocked HTTP responses more explicit and easier to control.

references

https://docs.snowflake.com/en/developer-guide/sql-api/reference
https://docs.snowflake.com/en/developer-guide/sql-api/reference#label-sql-api-reference-queryfailurestatus

@HyunWooZZ HyunWooZZ requested a review from potiuk as a code owner January 21, 2026 17:48
@boring-cyborg boring-cyborg Bot added area:providers provider:snowflake Issues related to Snowflake provider labels Jan 21, 2026

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM but you need to fix static checks. prek to the rescue

@choo121600 choo121600 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!
Just need to fix the static check failures 😀
You can follow the guidelines in the doc below to resolve them easily:

https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst

@HyunWooZZ

Copy link
Copy Markdown
Contributor Author

Thank you both for your help! :)
I’ve run prek and fixed the lint issues.

@potiuk could you review it again?

@HyunWooZZ

Copy link
Copy Markdown
Contributor Author

@potiuk
No rush at all, but I wanted to gently remind you about this PR.

@shahar1 shahar1 changed the title Fix: Handle HTTP 422 responses bypass to _process_response instead of raising immediately in Snowflake SQL API hook. Handle HTTP 422 responses bypass to _process_response instead of raising immediately in Snowflake SQL API hook. Feb 10, 2026
@shahar1 shahar1 merged commit 615a488 into apache:main Feb 10, 2026
89 checks passed
Alok-kumar-priyadarshi pushed a commit to Alok-kumar-priyadarshi/airflow that referenced this pull request Feb 11, 2026
Ratasa143 pushed a commit to Ratasa143/airflow that referenced this pull request Feb 15, 2026
choo121600 pushed a commit to choo121600/airflow that referenced this pull request Feb 22, 2026
AkshayArali pushed a commit to AkshayArali/airflow_630 that referenced this pull request Feb 27, 2026
AkshayArali pushed a commit to AkshayArali/airflow_630 that referenced this pull request Feb 27, 2026
Subham-KRLX pushed a commit to Subham-KRLX/airflow that referenced this pull request Mar 4, 2026
dominikhei pushed a commit to dominikhei/airflow that referenced this pull request Mar 11, 2026
Ankurdeewan pushed a commit to Ankurdeewan/airflow that referenced this pull request Mar 15, 2026
radhwene pushed a commit to radhwene/airflow that referenced this pull request Mar 21, 2026
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.

4 participants