justinmclean opened a new issue, #10171:
URL: https://github.com/apache/gravitino/issues/10171

   ### What would you like to be improved?
   
   Several REST endpoints dereference `request` fields (for example 
`request.getName()` or `request.getJobTemplateName()`) before entering their 
try block.
   
   If request deserialization yields `null` (for example empty body, literal 
JSON `null`, or binding edge cases), this can trigger an uncaught 
`NullPointerException` and bypasses expected `ExceptionHandlers` path.
   
   
   
   ### How should we improve?
   
   ## Scope
   - [ ] 
`server/src/main/java/org/apache/gravitino/server/web/rest/TableOperations.java`
 `createTable`
   - [ ] 
`server/src/main/java/org/apache/gravitino/server/web/rest/FilesetOperations.java`
 `createFileset`
   - [ ] 
`server/src/main/java/org/apache/gravitino/server/web/rest/FunctionOperations.java`
 `registerFunction`
   - [ ] 
`server/src/main/java/org/apache/gravitino/server/web/rest/ModelOperations.java`
 `registerModel`
   - [ ] 
`server/src/main/java/org/apache/gravitino/server/web/rest/SchemaOperations.java`
 `createSchema`
   - [ ] 
`server/src/main/java/org/apache/gravitino/server/web/rest/JobOperations.java` 
`registerJobTemplate`
   - [ ] 
`server/src/main/java/org/apache/gravitino/server/web/rest/JobOperations.java` 
`runJob`
   
   ## Expected behavior
   - No `request.get*()` access before null-safe handling.
   - Null request input should return stable structured error responses (for 
example, bad request / mapped handler response), not uncaught NPE.
   - Endpoint APIs and behavior to remain unchanged except for safer null 
handling.
   
   
   ## Definition of done
   - [ ] Remove pre-try request dereferences in listed methods.
   - [ ] Keep existing `ExceptionHandlers` mapping behavior.
   - [ ] Keep endpoint APIs unchanged.
   - [ ] Add/adjust unit tests for null request body behavior in matching REST 
test classes.
   - [ ] Run and pass: `./gradlew test -PskipITs`
   
   ## Example unit test
   ```java
   @Test
   public void testCreateTableWithNullRequestBody() {
     Response resp =
         target(tablePath(metalake, catalog, schema))
             .request(MediaType.APPLICATION_JSON_TYPE)
             .accept("application/vnd.gravitino.v1+json")
             .post(Entity.entity("null", MediaType.APPLICATION_JSON_TYPE));
   
     Assertions.assertEquals(Status.BAD_REQUEST.getStatusCode(), 
resp.getStatus());
   }
   ```


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