SameerMesiah97 commented on code in PR #70101:
URL: https://github.com/apache/airflow/pull/70101#discussion_r4027223651
##########
providers/snowflake/src/airflow/providers/snowflake/hooks/snowflake_cortex_agent.py:
##########
@@ -77,7 +108,22 @@ def _request(
response.raise_for_status()
- return response.json()
+ if not response.content:
+ if response_type == "dict":
+ return {}
+ raise TypeError("Expected list[dict] response, got empty response")
+
+ data = response.json()
+
+ if response_type == "dict":
+ if not isinstance(data, dict):
+ raise TypeError(f"Expected dict response, got
{type(data).__name__}")
+ return data
+
+ if not isinstance(data, list) or not all(isinstance(item, dict) for
item in data):
+ raise TypeError(f"Expected list[dict] response, got
{type(data).__name__}")
Review Comment:
The conditions have been split in to separate branches. A new test case has
been added to cover scenarios where the elements of the list are not of type
`dict`.
--
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]