kenny-ish opened a new pull request, #14330:
URL: https://github.com/apache/gravitino/pull/14330

   ### What changes were proposed in this pull request?
   
   `ParameterUtil.extractNameIdentifierFromParameters` now wraps the 
`IllegalArgumentException` from `MetadataObjects.parse` in 
`IllegalMetadataObjectException`, keeping the parse message. This is the same 
handling #12727 added for an invalid object type in the same method, and 
`GravitinoInterceptionService` already maps `IllegalMetadataObjectException` to 
400. The log message in that catch block no longer says "type", since it now 
covers both cases.
   
   ### Why are the changes needed?
   
   With authorization enabled, a metadata object name with the wrong number of 
parts for its type (for example `GET 
/api/metalakes/{metalake}/objects/table/a.b/tags` or 
`.../objects/schema/a.b.c/policies`) returned 500 with "Authorization failed 
due to system internal error. Please contact administrator.". 
`MetadataObjects.parse` throws a plain `IllegalArgumentException`, which is not 
one of the exceptions the interceptor maps to 400, so it fell into the generic 
`catch (Exception ex)` block.
   
   Fixes #14304
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. These requests now return HTTP 400 (`IllegalArgumentException`, code 
1001) with the parse message, for example "If the type is SCHEMA, the length of 
names must be 2", instead of HTTP 500.
   
   ### How was this patch tested?
   
   Added `testInvalidMetadataObjectNameReturnsBadRequest` to 
`TestGravitinoInterceptionService`. It passes a 3-part name for a schema 
through the interceptor and checks for 400, the parse message, and that the 
resource method is not invoked. The test fails with 500 without the fix.
   
   - `./gradlew :server:test --tests 
org.apache.gravitino.server.web.filter.TestGravitinoInterceptionService`
   - `./gradlew :server:test --tests 'org.apache.gravitino.server.web.filter.*'`
   - `./gradlew :server:spotlessCheck`
   


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