laserninja opened a new pull request, #10668: URL: https://github.com/apache/gravitino/pull/10668
### What changes were proposed in this pull request? Register a custom Jetty ErrorHandler (IcebergJsonErrorHandler) for the Iceberg REST server that writes Iceberg ErrorResponse JSON bodies instead of HTML error pages. Changes: - Added setErrorHandler(ErrorHandler) to JettyServer to allow replacing the default HTML error handler. - Created IcebergJsonErrorHandler that formats errors as JSON ErrorResponse with Content-Type: application/json. - Registered the handler in RESTService.initServer(). - Added TestIcebergJsonErrorHandler with 4 test cases. ### Why are the changes needed? When authentication fails, AuthenticationFilter calls resp.sendError() at the servlet filter level -- before the request reaches JAX-RS -- so IcebergExceptionMapper is never invoked. Jettys default ErrorHandler produces an HTML error page, violating the Iceberg REST API specification which requires all errors to be JSON ErrorResponse bodies. This causes Iceberg REST clients (e.g., Java RESTCatalog) to fail with a secondary JSON parse error, masking the real authentication failure. Fix: #10667 ### Does this PR introduce _any_ user-facing change? No API changes. Error responses from the Iceberg REST server for pre-JAX-RS failures (e.g., 401 Unauthorized) will now be properly formatted JSON instead of HTML, which is what clients already expect. ### How was this patch tested? Added TestIcebergJsonErrorHandler covering: 1. 401 Unauthorized returns correct JSON ErrorResponse 2. 500 Internal Server Error returns correct JSON ErrorResponse 3. Null error message falls back to HTTP status message 4. Empty error message falls back to HTTP status message All existing tests in server-common and iceberg-rest-server continue to pass. -- 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]
