ashb commented on code in PR #46827:
URL: https://github.com/apache/airflow/pull/46827#discussion_r1967430430


##########
airflow/api_fastapi/core_api/datamodels/log.py:
##########
@@ -16,11 +16,29 @@
 # under the License.
 from __future__ import annotations
 
-from pydantic import BaseModel
+from datetime import datetime
+from typing import Annotated
+
+from pydantic import BaseModel, ConfigDict, WithJsonSchema
+
+
+class StructuredLogMessage(BaseModel):
+    """An individual log message."""
+
+    # Not every message has a timestamp.
+    timestamp: Annotated[
+        datetime | None,
+        # Schema level, say this is always a datetime if it exists
+        WithJsonSchema({"type": "string", "format": "date-time"}),

Review Comment:
   This is to not include the `None` option as a possible value to the client. 
At the python level this is either a datetime, or one. But when we serialize 
this, if it's present it's always a datetime.
   
   So the override is needed so that the JS doesn't see the properly as 
possibly nullable. A subtle distinction but a distinction none the less.



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