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

   ### What would you like to be improved?
   
   ModelEventDispatcher.listModelVersionInfos() dispatches inconsistent 
listener events. The success path emits ListModelVersionInfosEvent with 
OperationType.LIST_MODEL_VERSION_INFOS, but the pre-event and failure-event use 
ListModelVersionPreEvent and ListModelVersionFailureEvent, both of which report 
OperationType.LIST_MODEL_VERSIONS.
   
   This makes the event stream inconsistent for the same API call. Any listener 
that keys behavior off operationType() will see listModelVersionInfos() as 
LIST_MODEL_VERSIONS before execution and on failure, but as 
LIST_MODEL_VERSION_INFOS on success. That can break auditing, filtering, and 
metrics for model version info lookups.
   
   Relevant code: ModelEventDispatcher.java (lines 414 and 422)
   
   
   
   ### How should we improve?
   
   Add dedicated pre-event and failure-event classes for 
listModelVersionInfos(), with operationType() returning 
LIST_MODEL_VERSION_INFOS, and update 
ModelEventDispatcher.listModelVersionInfos() to use them.
   
   The listener tests should also be updated so listModelVersionInfos() 
consistently asserts LIST_MODEL_VERSION_INFOS for pre, success, and failure 
events.
   
   Here's the failure unit test:
   ```
     @Test
     void testListModelVersionInfosFailureEvent() {
       Assertions.assertThrowsExactly(
           GravitinoRuntimeException.class,
           () -> failureDispatcher.listModelVersionInfos(existingIdentA));
   
       Event event = dummyEventListener.popPostEvent();
   
       Assertions.assertEquals(ListModelVersionFailureEvent.class, 
event.getClass());
       Assertions.assertEquals(
           GravitinoRuntimeException.class,
           ((ListModelVersionFailureEvent) event).exception().getClass());
       Assertions.assertEquals(OperationType.LIST_MODEL_VERSION_INFOS, 
event.operationType());
       Assertions.assertEquals(OperationStatus.FAILURE, 
event.operationStatus());
   
       ListModelVersionFailureEvent listModelVersionInfosFailureEvent =
           (ListModelVersionFailureEvent) event;
       Assertions.assertEquals(existingIdentA, 
listModelVersionInfosFailureEvent.identifier());
     }
   
   ```


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