phanipaladugula opened a new pull request, #60480:
URL: https://github.com/apache/airflow/pull/60480

   This Pull Request resolves a TypeError: 'str' object cannot be interpreted 
as an integer that occurs during DAG deserialization.
   
   In Airflow 3.x, fields like logical_date or start_date in a MappedOperator 
(via .partial()) can validly contain Jinja template strings (e.g., {{ 
ts_nodash_with_tz }}).
   
   During the deserialization process in 
airflow/serialization/serialized_objects.py, the method 
_deserialize_field_value uses a heuristic to identify date fields: it checks if 
a field name ends with _date. If it matches, it automatically passes the value 
to _deserialize_datetime.
   
   However, _deserialize_datetime (and the underlying from_timestamp utility) 
expects a numeric timestamp (int/float). When a template string is passed 
instead of a number, the system crashes because it cannot convert the raw Jinja 
string into a datetime object.
   
   I have added a type check in _deserialize_field_value within the 
OperatorSerialization class.
   
   If the value for a *_date field is an instance of str, the method now 
returns it immediately as-is.
   
   This allows the template string to persist through the deserialization phase 
so it can be rendered by the Task Instance at runtime.
   
   If the value is a number, it continues to be deserialized into a datetime 
object as before.
   
   Related Issue
   Fixes #60408
   
   Tests
   I have added a regression test: 
test_deserialization_of_templated_date_in_mapped_operator in 
airflow-core/tests/unit/serialization/test_dag_serialization.py.
   
   The test:
   
   Creates a TriggerDagRunOperator using .partial() with a Jinja string for 
logical_date.
   
   Simulates the full Serialization -> Deserialization cycle.
   
   Verifies that the deserialized operator preserves the template string and 
does not raise a TypeError.
   
   Notes to Reviewers
   I encountered environment path issues running tests locally on Windows 
(tests_common not found), but the logic has been implemented following the 
project's serialization patterns. Please rely on the CI/GitHub Actions results 
for final verification.


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