You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "laserninja (via GitHub)" <gi...@apache.org> on 2026/06/12 03:53:18 UTC

[PR] [#11581] fix: Return JSON ErrorResponse for 401/403 auth failures in AuthenticationFilter [gravitino]

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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11581] fix: Return JSON ErrorResponse for 401/403 auth failures in AuthenticationFilter [gravitino]

Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi merged PR #11614:
URL: https://github.com/apache/gravitino/pull/11614


-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11581] fix: Return JSON ErrorResponse for 401/403 auth failures in AuthenticationFilter [gravitino]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #11614:
URL: https://github.com/apache/gravitino/pull/11614#issuecomment-4687692762

   <!-- coverage-report -->
   ### Code Coverage Report
   |Overall Project|66.97%|:green_circle:|
   |:-|:-|:-:|
   |Files changed|65.54%|:green_circle:|
   <br>
   
   |Module|Coverage||
   |:-|:-|:-:|
   |aliyun|1.72%|:red_circle:|
   |api|46.82%|:green_circle:|
   |authorization-common|85.96%|:green_circle:|
   |aws|3.66%|:red_circle:|
   |azure|2.47%|:red_circle:|
   |catalog-common|10.4%|:red_circle:|
   |catalog-fileset|80.23%|:green_circle:|
   |catalog-glue|66.91%|:green_circle:|
   |catalog-hive|79.44%|:green_circle:|
   |catalog-jdbc-clickhouse|80.02%|:green_circle:|
   |catalog-jdbc-common|44.22%|:green_circle:|
   |catalog-jdbc-doris|80.28%|:green_circle:|
   |catalog-jdbc-hologres|54.03%|:green_circle:|
   |catalog-jdbc-mysql|79.23%|:green_circle:|
   |catalog-jdbc-oceanbase|78.38%|:green_circle:|
   |catalog-jdbc-postgresql|82.29%|:green_circle:|
   |catalog-jdbc-starrocks|78.51%|:green_circle:|
   |catalog-kafka|77.01%|:green_circle:|
   |catalog-lakehouse-generic|58.53%|:green_circle:|
   |catalog-lakehouse-hudi|79.1%|:green_circle:|
   |catalog-lakehouse-iceberg|85.79%|:green_circle:|
   |catalog-lakehouse-paimon|79.15%|:green_circle:|
   |catalog-model|77.72%|:green_circle:|
   |cli|44.51%|:green_circle:|
   |client-java|78.01%|:green_circle:|
   |common|49.88% **`+0.04%`**|:green_circle:|
   |core|82.38%|:green_circle:|
   |filesystem-hadoop3|77.27%|:green_circle:|
   |flink|0.0%|:red_circle:|
   |flink-common|45.72%|:green_circle:|
   |flink-runtime|0.0%|:red_circle:|
   |gcp|14.12%|:red_circle:|
   |hadoop-common|10.39%|:red_circle:|
   |hive-metastore-common|53.9%|:green_circle:|
   |iceberg-common|57.41%|:green_circle:|
   |iceberg-rest-server|73.92%|:green_circle:|
   |idp-basic|86.18%|:green_circle:|
   |integration-test-common|0.0%|:red_circle:|
   |jobs|66.17%|:green_circle:|
   |lance-common|20.79%|:red_circle:|
   |lance-rest-server|60.54%|:green_circle:|
   |lineage|53.02%|:green_circle:|
   |optimizer|82.95%|:green_circle:|
   |optimizer-api|21.95%|:red_circle:|
   |server|85.73%|:green_circle:|
   |server-common|73.79% **`+0.17%`**|:green_circle:|
   |spark|28.57%|:red_circle:|
   |spark-common|41.66%|:green_circle:|
   |trino-connector|40.13%|:green_circle:|
   
   <details>
   <summary>Files</summary>
   
   |Module|File|Coverage||
   |:-|:-|:-|:-:|
   |common|[ErrorResponse.java](https://github.com/laserninja/gravitino/blob/6f1b824c94b7ab629d6a3895a499eda0a65fe0ca/common/src/main/java/org/apache/gravitino/dto/responses/ErrorResponse.java)|53.16%|:red_circle:|
   ||[ErrorConstants.java](https://github.com/laserninja/gravitino/blob/6f1b824c94b7ab629d6a3895a499eda0a65fe0ca/common/src/main/java/org/apache/gravitino/dto/responses/ErrorConstants.java)|0.0%|:red_circle:|
   |server-common|[AuthenticationFilter.java](https://github.com/laserninja/gravitino/blob/6f1b824c94b7ab629d6a3895a499eda0a65fe0ca/server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java)|79.71%|:green_circle:|
   
   </details>


-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org