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

   ### What changes were proposed in this pull request?
   
   This PR fixes a bug in the exception handling of the `setPolicy` method in 
`PolicyOperations.java`.
   
   The `OperationType` variable is now determined from the request **before** 
the `try` block to ensure it's available in the `catch` block. The `catch` 
block now uses this dynamic variable instead of a hardcoded 
`OperationType.ENABLE`.
   
   ### Why are the changes needed?
   
   Previously, if an exception occurred while a user was trying to **disable** 
a policy via the PATCH API endpoint, the error handler would incorrectly report 
it as a failure of an **enable** operation. This was misleading and made 
debugging difficult.
   
   Fix: #8661
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. The error response returned to an API user when a `disable` policy 
operation fails is now correctly identified. There are no changes to the API's 
structure or success paths.
   
   ### How was this patch tested?
   
   - Added a new unit test, `testSetPolicyDisableFailure`, to 
`TestPolicyOperations.java`.
   - This test specifically mocks a `RuntimeException` during a 
`disablePolicy()` call.
   - It verifies that the API returns the expected `500 Internal Server Error` 
and that the error payload is correct.
   - Confirmed that all existing tests in the `:server` module continue to pass 
after the change.


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