laserninja opened a new pull request, #11614: URL: https://github.com/apache/gravitino/pull/11614
### What changes were proposed in this pull request? `AuthenticationFilter.sendAuthErrorResponse()` now writes a Gravitino `ErrorResponse` JSON body with `application/json` content type instead of calling `response.sendError()`, which triggered Jetty's default HTML error page. Changes: - **ErrorConstants**: Added `UNAUTHORIZED_CODE = 1011` - **ErrorResponse**: Added `unauthorized(type, message, throwable)` factory method - **AuthenticationFilter**: Rewrote `sendAuthErrorResponse()` to produce JSON for `UnauthorizedException` (401), `ForbiddenException` (403), and generic exceptions (500) - **TestAuthenticationFilter**: Updated existing tests to verify JSON output; added 3 new tests for 401, 403, and 500 JSON responses ### Why are the changes needed? `AuthenticationFilter` rejected unauthenticated requests with `response.sendError(status, message)`, which triggers Jetty's default HTML error page. REST clients expect a JSON error response body, causing them to fail parsing 401/403 responses and surface opaque errors. Fix: #11581 ### Does this PR introduce _any_ user-facing change? Yes. 401/403/500 error responses from the `AuthenticationFilter` now return a JSON body with `Content-Type: application/json` instead of HTML. ### How was this patch tested? - Updated existing unit tests to assert JSON body, content type, and status code - Added `testUnauthorizedErrorReturnsJsonBody`, `testForbiddenErrorReturnsJsonBody`, and `testInternalServerErrorReturnsJsonBody` - Verified `IcebergAuthenticationFilter` tests still pass (subclass overrides `sendAuthErrorResponse` independently) -- 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]
