pierrejeambrun commented on code in PR #46827:
URL: https://github.com/apache/airflow/pull/46827#discussion_r1967533273
##########
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:
like the key could be missing from the object ? Is that the use case ?
Yes unfortunately we do not have an easy way to specify that. Maybe we need
two distinct models…
Anyway we needed that at other places and we chose not to manually override
the generated json.
I’m not strong on that but I would recommend we don’t do it here as well.
At least for consistency, also because. null check on the front end is a one
liner anyway. And finally because the code and the spec could get out of sync
by manually doing that. What happens if the code actually return 200 ? Does
that raises a 422 or return a response not in line with the spec ?
--
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]