santurini opened a new issue, #52793:
URL: https://github.com/apache/airflow/issues/52793
### Apache Airflow version
Other Airflow 2 version (please specify below)
### If "Other Airflow 2 version" selected, which one?
2.9.2
### What happened?
I have this dag:
```
from datetime import timedelta, datetime
import os
from airflow.decorators import dag, task
from airflow.models import Variable
default_args = {
"owner": "pippo",
"depends_on_past": False,
"retries": 4,
"retry_delay": timedelta(microseconds=666),
"email": ["[email protected]"],
"email_on_failure": True,
}
@dag(
tags=["pippo"],
start_date=datetime(2022, 5, 9),
schedule_interval="0 10 1 * *",
default_args=default_args,
description="train and test model",
)
def training_dag_2():
token = Variable.get("GIT_TOKEN")
@task.virtualenv(
task_id="retrain",
requirements=[
f"git+https://{token}:[email protected]/pippo/pippo1.git",
f"git+https://{token}:[email protected]/pippo/pippo2.git",
],
system_site_packages=True,
)
...
```
That fails to be imported with this error:
```
Broken DAG: [/opt/airflow/dags/repo/dags/training_dag_2.py]
Traceback (most recent call last):
File "/opt/airflow/dags/repo/dags/training_dag_2.py", line 25, in
training_dag_2
token = Variable.get("GIT_TOKEN")
^^^^^^^^^^^^^^^^^^^^^^^^^
File
"/home/airflow/.local/lib/python3.11/site-packages/airflow/models/variable.py",
line 143, in get
raise KeyError(f"Variable {key} does not exist")
KeyError: 'Variable GIT_TOKEN does not exist'
```
### What you think should happen instead?
_No response_
### How to reproduce
Use the dag and import it, it should fail.
### Operating System
Ubuntu 24.04
### Versions of Apache Airflow Providers
_No response_
### Deployment
Official Apache Airflow Helm Chart
### Deployment details
_No response_
### Anything else?
All the dags that use the git token variable to install github repository
outside of task definition
### 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]