Fayupable opened a new pull request, #12791: URL: https://github.com/apache/gravitino/pull/12791
### What changes were proposed in this pull request? Several `create`/`register`/`add` REST operations called `request.validate()` without first checking for a null request body, so an empty or JSON `null` body dereferenced the request and returned HTTP 500 instead of a proper 400. Applied the existing `createMetalake` pattern (null-check first, then route an `IllegalArgumentException` through the corresponding exception handler) to: - Catalog, Schema, Table, Fileset, Topic, Policy, and Tag creation - Function, Model, and JobTemplate registration - User, Group, and Role creation - Bulk user and group creation Also updated a pre-existing test in `TestGroupOperations` that had asserted the old 500 status as expected behavior, and added a `WithNullRequest` test for each fixed operation, matching the `assertNullRequestBodyRejected` pattern from #12770. ### Why are the changes needed? A null request body currently returns HTTP 500 with an internal error response for these operations, instead of a structured 400. This is inconsistent with the already-fixed `alter`/`createView` operations (#12769, #12770) and with `createMetalake`, and it leaks an internal error to the caller for what is really a bad request. Fix: #12788 ### Does this PR introduce _any_ user-facing change? Yes. A `create`/`register`/`add` request with a null or empty body now returns HTTP 400 with error code `1001`, error type `IllegalArgumentException`, and a message stating the request body cannot be null, instead of HTTP 500. ### How was this patch tested? Added a `testXxxWithNullRequest()` test for each of the 14 fixed operations, verifying HTTP 400, error code `1001`, error type `IllegalArgumentException`, and the error message, using the shared `assertNullRequestBodyRejected` helper. Ran `:server:test` scoped to the 14 affected test classes: 176 tests, all passing. -- 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]
