Skip to content

Conversation

@HyunWooZZ
Copy link
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
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.

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

Copy link
Member

@choo121600 choo121600 left a comment

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
Contributor Author

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

@potiuk could you review it again?

@HyunWooZZ HyunWooZZ requested a review from potiuk January 22, 2026 06:54
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.

3 participants