niraj-mx07 opened a new issue, #12196:
URL: https://github.com/apache/gravitino/issues/12196

   ### Version
   
   main branch
   
   ### Describe what's wrong
   
   Currently, the Audit interface in 
clients/client-python/gravitino/api/audit.py defines the create_time and 
last_modified_time methods as returning datetime objects:   
    
    @abstractmethod
       def create_time(self) -> datetime:
           pass
   
   However, AuditDTO in clients/client-python/gravitino/dto/audit_dto.py, which 
implements Audit, returns a str instead. There are explicit TODO comments 
indicating that datetime deserialization from JSON is currently missing:
   
       _create_time: Optional[str] = field(
           default=None, metadata=config(field_name="createTime")
       )  # TODO: Can't deserialized datetime from JSON
   
   Why it needs to be improved: This causes a type mismatch at runtime. Any 
user relying on the Python client's Audit interface expects to work with 
datetime objects, but will surprisingly receive string representations.
   
   ### Error message and/or stacktrace
   
   # No explicit crash, but causes unexpected typing behavior in downstream 
code relying on datetime methods:
   audit_info = get_audit()
   time = audit_info.create_time()
   
   # This will fail at runtime because time is a str, not a datetime:
   print(time.year) 
   # AttributeError: 'str' object has no attribute 'year'
   
   
   ### How to reproduce
   
   1. Use the python client to interact with the Gravitino API and retrieve an 
entity containing Audit metadata (e.g., getting a Metalake).
   2. Call .audit().create_time() on the retrieved object.
   3. Observe that the returned type is a raw ISO-8601 string rather than a 
Python datetime object, contrary to the Audit interface definition.
   
   ### Additional context
   
   _No response_


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