jablecherman opened a new issue, #51632:
URL: https://github.com/apache/airflow/issues/51632
### Apache Airflow version
3.0.2
### If "Other Airflow 2 version" selected, which one?
_No response_
### What happened?
When running a dag via `dag.test()`, I receive an error when accessing the
jinja variable `{{ data_interval_end }}` and `{{ data_interval_end }}`.
Ex:
```
UndefinedError: 'data_interval_start' is undefined
```
The issue is not with all jinja variables. For example, `{{
task_instance_key_str }}` is defined when doing `dag.test()`.
### What you think should happen instead?
The jinja var should be used with no issue. This is the behavior in the UI
for all three of the jinja vars tested in the below reproducible example.
### How to reproduce
Run the below using dag.test(), only run one task at a time. I just comment
out the other two. You should see the error described in the comments above
each task.
```
from airflow import DAG
from airflow.providers.standard.operators.python import PythonOperator
from datetime import datetime
import logging
def test_task(jinja_var: str):
logging.info(f"Printing jinja var: {jinja_var}")
with DAG(
dag_id="testdag2",
schedule="@daily",
start_date=datetime(2024, 1, 1),
catchup=False,
) as dag:
# UndefinedError: 'data_interval_start' is undefined
task1 = PythonOperator(
task_id="task_data_interval_end",
python_callable=test_task,
op_kwargs={
"jinja_var": "{{ data_interval_end }}"
}
)
# UndefinedError: 'data_interval_end' is undefined
task2 = PythonOperator(
task_id="task_data_interval_start",
python_callable=test_task,
op_kwargs={
"jinja_var": "{{ data_interval_start }}"
}
)
# Works
task3 = PythonOperator(
task_id="task_task_instance_key_str",
python_callable=test_task,
op_kwargs={
"jinja_var": "{{ task_instance_key_str }}"
}
)
if __name__ == "__main__":
dag.test()
```
### Operating System
Debian GNU/Linux 12 (bookworm)
### Versions of Apache Airflow Providers
apache-airflow-providers-amazon==9.8.0
apache-airflow-providers-celery==3.11.0
apache-airflow-providers-cncf-kubernetes==10.4.3
apache-airflow-providers-common-compat==1.7.0
apache-airflow-providers-common-io==1.6.0
apache-airflow-providers-common-sql==1.27.1
apache-airflow-providers-elasticsearch==6.3.0
apache-airflow-providers-http==5.3.0
apache-airflow-providers-microsoft-azure==12.4.0
apache-airflow-providers-microsoft-mssql==4.3.0
apache-airflow-providers-mysql==6.3.0
apache-airflow-providers-odbc==4.10.0
apache-airflow-providers-openlineage==2.3.0
apache-airflow-providers-postgres==6.2.0
apache-airflow-providers-samba==4.10.0
apache-airflow-providers-sftp==5.3.0
apache-airflow-providers-slack==9.1.0
apache-airflow-providers-smtp==2.1.0
apache-airflow-providers-snowflake==6.3.1
apache-airflow-providers-ssh==4.1.0
apache-airflow-providers-standard==1.2.0
### Deployment
Official Apache Airflow Helm Chart
### 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]