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

   ### What changes were proposed in this pull request?
   
   Add null checks for request body parameters before accessing request fields 
in REST endpoints. Previously, if request deserialization yielded `null` (e.g., 
empty body, literal JSON `null`, or binding edge cases), accessing 
`request.getName()` or similar methods before the `try` block would trigger an 
uncaught `NullPointerException`, bypassing the expected `ExceptionHandlers` 
error handling path.
   
   ### Why are the changes needed?
   
   Several REST endpoints dereference `request` fields (e.g., 
`request.getName()`, `request.getJobTemplateName()`) before entering their 
`try` block. This causes uncaught NPEs that bypass the structured error 
response path, returning unhelpful 500 errors instead of proper 400 Bad Request 
responses.
   
   Fix #10171
   
   ### Does this PR introduce _any_ user-facing change?
   
   No API changes. Null request bodies now return a structured `400 Bad 
Request` error response instead of an unhandled `500 Internal Server Error`.
   
   ### How was this patch tested?
   
   Added unit tests for null request body behavior in all matching REST test 
classes:
   - `TestTableOperations.testCreateTableWithNullRequestBody`
   - `TestFilesetOperations.testCreateFilesetWithNullRequestBody`
   - `TestFunctionOperations.testRegisterFunctionWithNullRequestBody`
   - `TestModelOperations.testRegisterModelWithNullRequestBody`
   - `TestSchemaOperations.testCreateSchemaWithNullRequestBody`
   - `TestJobOperations.testRegisterJobTemplateWithNullRequestBody`
   - `TestJobOperations.testRunJobWithNullRequestBody`
   
   ### Affected endpoints
   
   | File | Method |
   |------|--------|
   | `TableOperations.java` | `createTable` |
   | `FilesetOperations.java` | `createFileset` |
   | `FunctionOperations.java` | `registerFunction` |
   | `ModelOperations.java` | `registerModel` |
   | `SchemaOperations.java` | `createSchema` |
   | `JobOperations.java` | `registerJobTemplate` |
   | `JobOperations.java` | `runJob` |


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