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

   ### What would you like to be improved?
   
   ListModelFailureEvent builds its inherited identifier() incorrectly in 
ListModelFailureEvent.java (line 42)
   
   It currently uses NameIdentifier.of(namespace.levels()), which turns the 
last namespace segment into the identifier name. For a namespace like 
metalake.catalog.schema, the event identifier becomes equivalent to model 
schema in namespace metalake.catalog, instead of representing the schema 
namespace being listed.
   
   This can produce incorrect metadata for listeners and audit logging that 
read event.identifier() on failed listModels(...) operations.
   
   ### How should we improve?
   
   Construct the event identifier so it truly represents the namespace being 
listed, consistent with the BaseEvent.identifier() contract for list operations.
   
   A simple fix would be to explicitly build a namespace-style identifier for 
the list target and add a unit test that validates both namespace() and 
identifier().
   
   Here the test to help:
   ```
   @Test
     void 
testListModelFailureEventIdentifierDoesNotTreatNamespaceLeafAsModelName() {
       Assertions.assertThrowsExactly(
           GravitinoRuntimeException.class, () -> 
failureDispatcher.listModels(namespace));
   
       Event event = dummyEventListener.popPostEvent();
       Assertions.assertEquals(ListModelFailureEvent.class, event.getClass());
   
       ListModelFailureEvent listModelFailureEvent = (ListModelFailureEvent) 
event;
       Assertions.assertEquals(namespace, listModelFailureEvent.namespace());
       Assertions.assertNotEquals(namespace.level(2), 
listModelFailureEvent.identifier().name());
     }
   ```


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