jgoedeke opened a new issue, #72319:
URL: https://github.com/apache/airflow/issues/72319

   ### Under which category would you file this issue?
   
   Task SDK
   
   ### Apache Airflow version
   
   3.3.0
   
   ### What happened and how to reproduce it?
   
   The scheduler crashes while creating an asset-triggered DAG run for a DAG 
with a `DeadlineAlert` interval of `timedelta(minutes=45)`.
   
   The serialized DAG payload observed in the scheduler traceback contains:
   
   ```python
   {
       "__classname__": "datetime.timedelta",
       "__version__": 2,
       "__data__": 2700,
   }
   ```
   
   The SDK datetime deserializer only accepts `str | float` for 
`datetime.timedelta`:
   
   ```python
   if cls is datetime.timedelta and isinstance(data, str | float):
       return datetime.timedelta(seconds=float(data))
   ```
   
   Since `2700` is an `int`, deserialization raises:
   
   ```text
   TypeError: unknown date/time format datetime.timedelta
   ```
   
   The exception is unhandled in scheduler DAG-run creation and terminates the 
scheduler process.
   
   ### Minimal reproduction
   
   ```python
   from datetime import timedelta
   
   from airflow.sdk.serde import CLASSNAME, DATA, VERSION, deserialize
   
   serialized_timedelta = {
       CLASSNAME: "datetime.timedelta",
       VERSION: 2,
       DATA: 2700,
   }
   
   assert deserialize(serialized_timedelta) == timedelta(minutes=45)
   ```
   
   ### Actual result
   
   ```text
   TypeError: unknown date/time format datetime.timedelta
   ```
   
   ### Expected result
   
   ```python
   timedelta(minutes=45)
   ```
   
   ### Proposed fix
   
   Accept integer second values alongside the already accepted string and float 
forms.
   
   
   ### What you think should happen instead?
   
   _No response_
   
   ### Operating System
   
   _No response_
   
   ### Deployment
   
   None
   
   ### Apache Airflow Provider(s)
   
   _No response_
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Official Helm Chart version
   
   Not Applicable
   
   ### Kubernetes Version
   
   _No response_
   
   ### Helm Chart configuration
   
   _No response_
   
   ### Docker Image customizations
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


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