atul-astronomer opened a new issue, #47370:
URL: https://github.com/apache/airflow/issues/47370
### Apache Airflow version
3.0.0
### If "Other Airflow 2 version" selected, which one?
_No response_
### What happened?
Fetching templated fields is failing.
```typescript
[2025-03-05T05:48:43.892005Z] ERROR - Task failed with exception
logger="task"
error_detail=[{"exc_type":"AttributeError","exc_value":"'Response' object has
no attribute
'dag_id'","syntax_error":null,"is_cause":false,"frames":[{"filename":"/opt/airflow/task_sdk/src/airflow/sdk/execution_time/task_runner.py","lineno":605,"name":"run"},{"filename":"/opt/airflow/task_sdk/src/airflow/sdk/execution_time/task_runner.py","lineno":726,"name":"_execute_task"},{"filename":"/opt/airflow/airflow/models/baseoperator.py","lineno":168,"name":"wrapper"},{"filename":"/opt/airflow/airflow/decorators/base.py","lineno":252,"name":"execute"},{"filename":"/opt/airflow/airflow/models/baseoperator.py","lineno":168,"name":"wrapper"},{"filename":"/opt/airflow/providers/standard/src/airflow/providers/standard/operators/python.py","lineno":196,"name":"execute"},{"filename":"/opt/airflow/providers/standard/src/airflow/providers/standard/operators/python.py","lineno":222,"name":"execute_callable"},{"filename":
"/opt/airflow/airflow/utils/operator_helpers.py","lineno":261,"name":"run"},{"filename":"/files/dags/decorated_rendered_templates.py","lineno":39,"name":"templated1"},{"filename":"/opt/airflow/airflow/utils/session.py","lineno":98,"name":"wrapper"},{"filename":"/opt/airflow/airflow/models/renderedtifields.py","lineno":172,"name":"get_templated_fields"}]}]
```
### What you think should happen instead?
DAG should pass as it was passing in Airflow 2
### How to reproduce
Run the below DAG in AF3 beta1 version:
```python
from airflow.models import DAG
from airflow.decorators import task
from pendulum import today
from airflow.models.renderedtifields import RenderedTaskInstanceFields as
rtif
from airflow import settings
from dags.plugins.api_utility import get_task_instance
from datetime import datetime, timedelta
docs = """
####Purpose
The purpose of this dag is to check that rendered templates, which are found
in the task details in the UI, are rendering the correct datatypes with python
decorated tasks.\n
It achieves this test by using the RenderedTaskInstanceFields from
airflow.models.renderedtifields to assert the xcom arg datatypes.
####Expected Behavior
This dag has 3 tasks that are all expected to succeed.
"""
@task
def pusher1(dict1):
return dict1
@task
def pusher2(template2):
return template2
@task
def templated1(**context):
sesh = settings.Session()
dag_id = context['dag'].dag_id
print(dag_id)
run_id = context['run_id']
get_ti1 = get_task_instance(dag_id, run_id, "pusher1")
get_ti2 = get_task_instance(dag_id, run_id, "pusher2")
print(get_ti1)
print(get_ti2)
temp_fields_task1 = rtif.get_templated_fields(get_ti1, sesh)
temp_fields_task2 = rtif.get_templated_fields(get_ti2, sesh)
print(f"This is the 1st tasks rendered_template_fields
{temp_fields_task1}")
print(f"This is the 2nd tasks rendered_template_fields
{temp_fields_task2}")
print(
f"""
The 1st tasks xcom arg datatype is
{type(temp_fields_task1['op_args'][0])}
And the 2nd tasks xcom arg datatype is
{type(temp_fields_task2['op_args'][0])}
"""
)
assert isinstance(temp_fields_task1["op_args"][0], list) == True
assert isinstance(temp_fields_task2["op_args"][0], dict) == True
assert temp_fields_task1["op_args"][0] == [
'hello_world', '01234567-8910-1112-1314-151617181920'
]
assert float(temp_fields_task2["op_args"][0]['key1']) > 0 and
float(temp_fields_task2["op_args"][0]['key1']) < 1
with DAG(
dag_id="check_decorated_rendered_templates",
start_date=datetime(2021, 1, 1),
schedule=timedelta(days=61),
doc_md=docs,
max_active_runs=3,
tags=["core"],
) as dag:
t1 = pusher1(["hello_world", '{{
macros.uuid.UUID("01234567891011121314151617181920") }}'])
t2 = pusher2({"key1": '{{ macros.random() }}'})
t3 = templated1()
t1 >> t2 >> t3
```
### Operating System
Linux
### Versions of Apache Airflow Providers
_No response_
### Deployment
Other
### Deployment details
_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]