freesinger opened a new pull request, #10818:
URL: https://github.com/apache/gravitino/pull/10818
<!--
1. Title: [#<issue>] <type>(<scope>): <subject>
Examples:
- "[#123] feat(operator): Support xxx"
- "[#233] fix: Check null before access result in xxx"
- "[MINOR] refactor: Fix typo in variable name"
- "[MINOR] docs: Fix typo in README"
- "[#255] test: Fix flaky test NameOfTheTest"
Reference: https://www.conventionalcommits.org/en/v1.0.0/
2. If the PR is unfinished, please mark this PR as draft.
-->
### What changes were proposed in this pull request?
This PR improves error handling in the Java client when the server (or an
auth gateway/filter) returns HTTP 401/403 with an empty or non-JSON response
body.
Specifically, it makes the HTTP client build a status-aware ErrorResponse
for 401/403 when the body is missing/unparseable, and ensures the generic REST
error handler throws UnauthorizedException / ForbiddenException accordingly.
It also keeps HTTP status code context in empty-body error messages to
preserve existing expectations in client tests.
### Why are the changes needed?
In real deployments, authentication/authorization failures are frequently
generated by gateways or filters and may not return a Gravitino JSON error
body. Previously, such responses could be surfaced as a generic RESTException,
losing the 401/403 semantics and making it harder for applications to handle
auth errors reliably.
Fix: N/A
### Does this PR introduce _any_ user-facing change?
Yes.
Java client calls that receive HTTP 401/403 may now consistently throw
UnauthorizedException / ForbiddenException even when the response body is empty
or not JSON (previously could be a generic RESTException).
### How was this patch tested?
```bash
./gradlew :clients:client-java:test \
--tests org.apache.gravitino.client.TestGravitinoAdminClient \
--tests org.apache.gravitino.client.TestHTTPClient
```
--
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]