tushardev-365 opened a new pull request, #71938:
URL: https://github.com/apache/airflow/pull/71938
MwaaHook's local-session-token fallback logs the error body inside its
`except requests.HTTPError` handler like this:
```python
except requests.HTTPError as e:
self.log.error(e.response.json())
raise
```
`e.response.json()` is unguarded, so when the MWAA web server answers with a
non-JSON body, which is what an HTML error page from a proxy or load balancer
on a 502 or 504 looks like, the parse raises `JSONDecodeError` inside the
handler. That exception replaces the `HTTPError`, the `raise` on the next line
never runs, and callers catching `HTTPError` (or matching on status code) miss
the failure entirely. The log line that was supposed to help debug the failure
is what destroys it.
This is the same shape as #71702 in the Dataprep hook, found by sweeping
other providers for the pattern. The fix mirrors it: guard the parse, fall back
to `e.response.text`, and let the original `HTTPError` propagate. `ValueError`
covers `JSONDecodeError` whether requests is backed by stdlib json or
simplejson.
The new test mirrors the existing
`test_invoke_rest_api_using_local_session_token_failure` exactly, with the mock
response's `.json()` raising `JSONDecodeError` and `.text` carrying an HTML
body: the `HTTPError` must still propagate and the raw text must be what gets
logged. Reverting only the source change makes the new test fail with the
leaked `JSONDecodeError`, so it pins the bug.
I was not able to run the provider test suite locally (no Airflow dev
environment on this machine); both files compile, and the test is a
line-for-line variation of its passing sibling. Happy to adjust if CI disagrees.
^ 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+Improvement+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]