MartinKChen opened a new issue #18970: URL: https://github.com/apache/airflow/issues/18970
### Apache Airflow version 2.0.2 ### Operating System Linux (AWS MWAA) ### Versions of Apache Airflow Providers _No response_ ### Deployment MWAA ### Deployment details _No response_ ### What happened Airflow raises exception when register sensor tasks if execution_date_fn/execution_delta is passed. Since function and timedelta could not be serialized when execute json.dumps at [airflow/models/sensorinstance, FUNCTION register](https://github.com/apache/airflow/blob/e6c56c4ae475605636f4a1b5ab3884383884a8cf/airflow/models/sensorinstance.py#L94) - Exception when execution_date_fn is passed `[2021-10-14 03:27:05,754] {{taskinstance.py:1303}} ERROR - Object of type function is not JSON serializable Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/airflow/models/taskinstance.py", line 1298, in _prepare_and_execute_task_with_callbacks registered = task_copy.register_in_sensor_service(self, context) File "/usr/local/lib/python3.7/site-packages/airflow/sensors/base.py", line 163, in register_in_sensor_service return SensorInstance.register(ti, poke_context, execution_context) File "/usr/local/lib/python3.7/site-packages/airflow/utils/session.py", line 70, in wrapper return func(*args, session=session, **kwargs) File "/usr/local/lib/python3.7/site-packages/airflow/models/sensorinstance.py", line 114, in register encoded_poke = json.dumps(poke_context) File "/usr/lib64/python3.7/json/__init__.py", line 231, in dumps return _default_encoder.encode(obj) File "/usr/lib64/python3.7/json/encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "/usr/lib64/python3.7/json/encoder.py", line 257, in iterencode return _iterencode(o, 0) File "/usr/lib64/python3.7/json/encoder.py", line 179, in default raise TypeError(f'Object of type {o.__class__.__name__} ' TypeError: Object of type function is not JSON serializable` - Exception when execution_delta is passed `[2021-10-14 05:54:58,526] {{taskinstance.py:1303}} ERROR - Object of type timedelta is not JSON serializable Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/airflow/models/taskinstance.py", line 1298, in _prepare_and_execute_task_with_callbacks registered = task_copy.register_in_sensor_service(self, context) File "/usr/local/lib/python3.7/site-packages/airflow/sensors/base.py", line 163, in register_in_sensor_service return SensorInstance.register(ti, poke_context, execution_context) File "/usr/local/lib/python3.7/site-packages/airflow/utils/session.py", line 70, in wrapper return func(*args, session=session, **kwargs) File "/usr/local/lib/python3.7/site-packages/airflow/models/sensorinstance.py", line 114, in register encoded_poke = json.dumps(poke_context) File "/usr/lib64/python3.7/json/__init__.py", line 231, in dumps return _default_encoder.encode(obj) File "/usr/lib64/python3.7/json/encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "/usr/lib64/python3.7/json/encoder.py", line 257, in iterencode return _iterencode(o, 0) File "/usr/lib64/python3.7/json/encoder.py", line 179, in default raise TypeError(f'Object of type {o.__class__.__name__} ' TypeError: Object of type timedelta is not JSON serializable` ### What you expected to happen _No response_ ### How to reproduce _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]
