CptTZ opened a new issue, #34641:
URL: https://github.com/apache/airflow/issues/34641
### Apache Airflow version
2.7.1
### What happened
I have a PythonOperator using a dictionary as `op_args`. When I enable
`render_template_as_native_obj`, a string value (but only with numeric chars,
i.e. `"life": "42"`) in the dict will be converted to int.
I did more researches and it seems the root cause is with `py` as
`template_fields_renderers`. I didn't look further into Airflow implementation
but I can help with debugging.
### What you think should happen instead
No field type conversion should ever happen.
### How to reproduce
DAG file:
```python
from datetime import datetime
from airflow import DAG
from airflow.operators.python import PythonOperator
from airflow.operators.smooth import SmoothOperator
BUGGY_DICT = {
"t1": 123,
"t4": "GOOD STR",
"life": "42",
}
def a_py_fun(a):
print(f"XX: {a}")
print(f"XX type: {type(a['life'])}")
with DAG(
dag_id='test',
schedule=None,
start_date=datetime(2023, 1, 1),
catchup=False,
render_template_as_native_obj=True, # Or False
) as dag:
d = PythonOperator(
task_id="py_bug",
python_callable=a_py_fun,
op_args=[BUGGY_DICT],
)
d >> SmoothOperator(task_id="xxx")
if __name__ == "__main__":
dag.test()
```
---
When `render_template_as_native_obj` is `True`:
```
...
XX: {'t1': 123, 't4': 'GOOD STR', 'life': 42}
XX type: <class 'int'>
...
```
When `render_template_as_native_obj` is `False`:
```
...
XX: {'t1': 123, 't4': 'GOOD STR', 'life': '42'}
XX type: <class 'str'>
...
```
### Operating System
Likely OS agnostic, reproducible on Ubuntu and macOS
### Versions of Apache Airflow Providers
N/A
### Deployment
Virtualenv installation
### Deployment details
`pip install apache-airflow==2.7.1`
### Anything else
_No response_
### Are you willing to submit PR?
- [X] 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]