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


##########
airflow/api_fastapi/execution_api/datamodels/taskinstance.py:
##########
@@ -83,6 +83,16 @@ class TIDeferredStatePayload(BaseModel):
     next_method: str
     trigger_timeout: timedelta | None = None
 
+    @field_validator("trigger_kwargs")
+    def validate_moment(cls, v):
+        if "moment" in v and isinstance(v["moment"], str):
+            moment_adapter = TypeAdapter(AwareDatetime)
+            try:
+                v["moment"] = 
moment_adapter.validate_strings(v["moment"].replace("Z", "+00:00"))

Review Comment:
   You shouldn't need the replace anymore, and nit: lets move that TypeAdapter 
to not be created every time (so `AwareDatetimeAdapter = 
TypeAdapter(AwareDatetime)` at the top-level of the module etc.
   
   ```suggestion
                   v["moment"] = 
AwareDatetimeAdapter.validate_strings(v["moment"])
   ```
   
   We could also _possibly_ let the validation error from the type adapter be 
thrown as it is.



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