tushardev-365 opened a new pull request, #71702:
URL: https://github.com/apache/airflow/pull/71702

   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   -->
   
   `GoogleDataprepHook._raise_for_status` logs a detail from the error body 
before re-raising,
   but it parses that body inside the handler with no guard:
   
   ```python
   def _raise_for_status(self, response: requests.models.Response) -> None:
       try:
           response.raise_for_status()
       except HTTPError:
           self.log.error(response.json().get("exception"))
           raise
   ```
   
   When the body is not a JSON object, `response.json()` raises and replaces 
the `HTTPError`, so
   the `raise` on the next line never runs and the caller loses the real 
status. `.get()` also
   assumes the parsed body is a dict.
   
   Behaviour before and after, for the same failing response:
   
   | error body | before | after |
   |---|---|---|
   | `{"exception": {...}}` | `HTTPError` | `HTTPError` |
   | `<html>502 Bad Gateway</html>` | `JSONDecodeError` | `HTTPError` |
   | empty | `JSONDecodeError` | `HTTPError` |
   | `["boom"]` | `AttributeError` | `HTTPError` |
   
   A proxy or load balancer in front of Dataprep answering 502 with an HTML 
page, or an empty
   401 or 504, is enough to trigger it.
   
   This matters beyond one call site: every Dataprep API method on the hook 
funnels through
   `_raise_for_status`, so the masking applies to all of them.
   
   The fix reads the detail through a small helper that falls back to 
`response.text`, so the
   `HTTPError` is always what propagates. The successful path is unchanged.
   
   ### Tests
   
   Four cases added covering a well-formed JSON body, a non-JSON body, a JSON 
array body, and a
   successful response, each asserting that the `HTTPError` is what surfaces.
   
   I was not able to run the provider suite locally, since Airflow is not 
installed in this
   environment. The before and after table above comes from exercising the 
handler's logic
   directly with the same four bodies.
   
   ---
   
   <!-- Please keep an empty line above the dashes. -->
   ^ Add meaningful description above
   Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
 for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improyments+Proposals))
 is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party 
License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a 
newsfragment file, named `{pr_number}.significant.rst` or 
`{issue_number}.significant.rst`, in 
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
   


-- 
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]

Reply via email to