laserninja commented on code in PR #10668:
URL: https://github.com/apache/gravitino/pull/10668#discussion_r3035910374


##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergRESTUtils.java:
##########
@@ -42,6 +44,25 @@
 
 public class IcebergRESTUtils {
 
+  /**
+   * Error type names matching the Iceberg REST API specification examples. 
See <a
+   * 
href="https://github.com/apache/iceberg/blob/main/open-api/rest-catalog-open-api.yaml";>Iceberg
+   * REST API spec</a>.
+   */
+  public static final Map<Integer, String> ERROR_TYPE_NAMES =
+      ImmutableMap.<Integer, String>builder()
+          .put(HttpServletResponse.SC_BAD_REQUEST, "BadRequestException")
+          .put(HttpServletResponse.SC_UNAUTHORIZED, "NotAuthorizedException")
+          .put(HttpServletResponse.SC_FORBIDDEN, "NotAuthorizedException")

Review Comment:
   1. **403 → "ForbiddenException"**: Fixed `ERROR_TYPE_NAMES` to map 403 to 
`"ForbiddenException"` instead of `"NotAuthorizedException"`.
   
   2. **Explicit exception conversion**: Added 
`IcebergExceptionMapper.convertToIcebergException(Exception)` that converts:
      - `UnauthorizedException` (Gravitino) → `NotAuthorizedException` (Iceberg)
      - `ForbiddenException` (Gravitino) → `ForbiddenException` (Iceberg)
      - Already-mapped Iceberg exceptions → passed through
      - Unknown exceptions → `ServiceFailureException` (Iceberg)
   
   3. **Filter uses converted exceptions**: `IcebergAuthenticationFilter` now 
converts the exception first via `convertToIcebergException()`, then uses the 
Iceberg exception's `getClass().getSimpleName()` as the type, no more 
status-code-to-string-name lookup in the filter path.



-- 
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]

Reply via email to