jiangxt2 opened a new pull request, #14366:
URL: https://github.com/apache/gravitino/pull/14366
### What changes were proposed in this pull request?
Preserve existing Gravitino and OAuth2 domain exceptions and add a safe
fallback for empty, malformed or unreadable HTTP error responses. Close HTTP
error responses, add focused unit and real HTTP regression coverage, and
document the exception contract.
### Why are the changes needed?
A gateway returning HTTP 502 with an HTML body can surface as a JSON
decoding error, obscuring the original HTTP failure and request context.
Fixes #14337.
### Does this PR introduce _any_ user-facing change?
Fallback failures now raise `HTTPResponseException`, a subclass of
`RESTException`, with `status_code`, `request_method` and `endpoint`
attributes. The endpoint contains only the scheme, hostname and optional port;
fallback diagnostics omit credentials, paths, request data and raw response
data.
Empty or invalid error responses bypass custom error handlers. Valid
structured errors retain their existing domain exceptions. Retry and
authentication behavior remain unchanged.
### How was this patch tested?
Source test preparation with the development dependencies installed:
`PYTHONPATH=clients/client-python python
clients/client-python/scripts/generate_version.py`.
- Python 3.12.9: 1,269 unit tests passed with `PYTHONPATH=../.. python -m
coverage run --branch -m unittest -v` from
`clients/client-python/tests/unittests`.
- Real HTTP regression tests: 2 tests passed with
`PYTHONPATH=clients/client-python python -m unittest -v
tests.integration.test_http_client_errors`, covering gateway responses,
truncated bodies, read timeouts, recovery and structured Gravitino/OAuth2
errors.
- Gravitino 2.0.0-SNAPSHOT with JDK 17: built the server with `./gradlew
compileDistribution -x test`, then ran the following against the running local
server; both tests passed:
```sh
GRAVITINO_HOME="$PWD/distribution/package" START_EXTERNAL_GRAVITINO=true \
PROJECT_VERSION=2.0.0-SNAPSHOT PYTHONPATH=clients/client-python \
python -m unittest -v \
tests.integration.test_metalake.TestMetalake.test_failed_create_metalake \
tests.integration.test_metalake.TestMetalake.test_failed_load_metalakes
```
- Python 3.10.18: installed the built source distribution in an isolated
environment and verified imports, fallback error context and structured domain
errors.
- `python -m pylint ./gravitino ./tests ./scripts` and `python -m black
--check ./gravitino ./tests ./scripts` from `clients/client-python`, plus
`./gradlew rat` from the repository root: passed.
--
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]