HyunWooZZ opened a new pull request, #60891:
URL: https://github.com/apache/airflow/pull/60891
## 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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]