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

   ### What changes were proposed in this pull request?
   
   - Guard `ViewOperations.createView` against a null request before accessing 
any
     request fields or invoking `request.validate()`.
   - Route the validation failure through the existing view exception handler so
     the endpoint returns a structured HTTP 400 response.
   - Cache the view name after the null guard and reuse it for logging, 
identifier
     construction, and catch-path error handling.
   - Add `TestViewOperations` coverage for an empty/null request entity.
   - Verify that malformed JSON continues to use the existing JSON exception
     mappers and returns HTTP 400.
   
   ### Why are the changes needed?
   
   An empty create-view request currently causes `ViewOperations.createView` to
   dereference `request` before null validation. This produces an unhandled HTTP
   500 response with an empty body instead of the structured client-error 
response
   used by other REST endpoints.
   
   The change follows the existing null-request handling pattern in
   `MetalakeOperations.createMetalake`.
   
   Fix: #12769
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. A create-view request with an empty or null body now returns a 
structured
   HTTP 400 response instead of an empty HTTP 500 response.
   
   There are no API schema or configuration changes. Valid requests and 
malformed
   JSON handling are unchanged.
   
   ### How was this patch tested?
   
   Before the fix, the null-request regression test failed with:
   
   ```text
   expected: <400> but was: <500>
   ```
   
   The malformed-JSON regression test passed independently, confirming that the
   existing mapper behavior was not the cause.
   
   After the fix:
   
   ```shell
   ./gradlew :server:test \
     --tests org.apache.gravitino.server.web.rest.TestViewOperations \
     -PskipITs --no-daemon
   ```
   
   Result: 9 tests passed, 0 failures, 0 errors.
   
   Additional checks:
   
   ```shell
   ./gradlew :server:spotlessCheck --no-daemon
   git diff --check
   ```
   
   Both checks passed.
   


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