lasdf1234 commented on code in PR #14556:
URL: https://github.com/apache/gravitino/pull/14556#discussion_r4453999683


##########
lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/service/LanceExceptionMapper.java:
##########
@@ -95,6 +102,53 @@ public Response toResponse(Throwable ex) {
     return toRESTResponse("", ex);
   }
 
+  private static Response handleWebApplicationException(
+      String instance, WebApplicationException exception) {
+    int status = exception.getResponse().getStatus();
+    String message = exception.getMessage();
+    if (exception instanceof ParamException parameterException) {
+      // Jersey can use 404 for parameter conversion failures, but these are 
invalid input.
+      status = Response.Status.BAD_REQUEST.getStatusCode();
+      message = "Invalid value for parameter '" + 
parameterException.getParameterName() + "'";
+    }
+    LanceNamespaceException error;
+    // Framework 404s describe route misses, not an identified missing table 
or namespace.
+    // Keep their HTTP status, while using INVALID_INPUT instead of an 
entity-not-found body code.
+    if (status >= 400 && status < 500) {
+      error =
+          switch (status) {
+            case 401 -> new UnauthenticatedException(message, "", instance);
+            case 403 -> new PermissionDeniedException(message, "", instance);
+            case 404 -> new InvalidInputException(message, "", instance);

Review Comment:
   **P1** — Framework 404 (including unimplemented Lance Namespace routes such 
as `/v1/table/{id}/query`) is mapped to `InvalidInputException` 
(`INVALID_INPUT`).
   
   Lance clients key off the JSON `code`: unimplemented ops need 
**`Unsupported` (code 0) with HTTP 406** so connectors can fall back 
([#14204](https://github.com/apache/gravitino/issues/14204)). Treating route 
misses as invalid input makes them indistinguishable from malformed requests 
and blocks that fallback.
   
   Consider mapping unimplemented/spec-missing routes to 
`UnsupportedOperationException` (you already do this for 405/406/415 on 
L123–124), or at least distinguish true bad paths from “operation not 
implemented”.



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