dennismdejong opened a new pull request, #13670:
URL: https://github.com/apache/gravitino/pull/13670

   ### What changes were proposed in this pull request?
   
   Guard the REST operations that still dereferenced a null request body:
   
   - `BulkOperations.addRoles` / `removeRoles`: reject a null body the same way 
as
     the sibling bulk user/group operations (`handleRoleException`, HTTP 400).
   - `JobOperations.runJob`: guard the null body before the log statement that
     dereferences the request.
   - `CatalogOperations.setCatalog` / `MetalakeOperations.setMetalake`: compute 
the
     operation type once and use it in the catch blocks instead of re-reading
     `request`, so no error path touches the request body.
   
   Note: the permission endpoints named in the issue (`revokeRolesFromUser` and
   siblings) are already guarded on main (handled by #12590 / #12866), so no 
change
   is needed there; this PR completes the same pattern for the operations that 
were
   still missing it.
   
   ### Why are the changes needed?
   
   An omitted, empty, or JSON `null` request body is a client error, but these
   endpoints answered it with HTTP 500 through an unintended 
NullPointerException
   (in the handler, or before the `try` block for `runJob`), masking the 
original
   failure and diverging from every other REST operation.
   
   Fix: #10166
   
   ### Does this PR introduce _user-facing_ change?
   
   Yes, for those three operations a null body now returns HTTP 400 with error 
code
   `1001` (`IllegalArgumentException`, message "Request body cannot be null")
   instead of HTTP 500. Valid requests are unchanged.
   
   ### How was this patch tested?
   
   - New regression tests (`testBulkAddRolesWithNullRequest`,
     `testBulkRemoveRolesWithNullRequest`, `testRunJobWithNullRequest`) fail 
before
     the change (expected 400, got 500) and pass after.
   - `JAVA_HOME=/opt/homebrew/opt/openjdk@17 ./gradlew :server:test -PskipITs`:
     64 test classes, 559 tests, 0 failures.
   - `./gradlew :server:spotlessCheck` passes.
   


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