dinigo opened a new issue #20857:
URL: https://github.com/apache/airflow/issues/20857
### Apache Airflow version
2.2.3 (latest released)
### What happened
I'm working on an operator that receives a lot of params, by convention with
the rest of the developers one of the named params is called `output`. However
when you add this param to the `templated_fields` airflow Fails with the
mentioned Exception
It seems like a reasonable name for a param. I've given a look at the
`airflow.utils.dag_cycle_tester` but I couln't find the reason why this is
raising the exception
```
Traceback (most recent call last):
File
"/home/airflow/.local/lib/python3.9/site-packages/airflow/models/dagbag.py",
line 402, in _process_modules
self.bag_dag(dag=dag, root_dag=dag)
File
"/home/airflow/.local/lib/python3.9/site-packages/airflow/models/dagbag.py",
line 426, in bag_dag
self._bag_dag(dag=dag, root_dag=root_dag, recursive=True)
File
"/home/airflow/.local/lib/python3.9/site-packages/airflow/models/dagbag.py",
line 434, in _bag_dag
check_cycle(dag) # throws if a task cycle is found
File
"/home/airflow/.local/lib/python3.9/site-packages/airflow/utils/dag_cycle_tester.py",
line 76, in check_cycle
child_to_check = _check_adjacent_tasks(current_task_id, task)
File
"/home/airflow/.local/lib/python3.9/site-packages/airflow/utils/dag_cycle_tester.py",
line 62, in _check_adjacent_tasks
raise AirflowDagCycleException(msg)
airflow.exceptions.AirflowDagCycleException: Cycle detected in DAG. Faulty
task: test_template_output_task
```
### What you expected to happen
Should be able to template this `output` param
### How to reproduce
Simply try the following
```python
from datetime import datetime
from airflow import DAG
from airflow.models import BaseOperator
class TemplateOutputOperator(BaseOperator):
template_fields = ['output']
def __init__(self, output: str = None, *args, **kwargs):
super(TemplateOutputOperator, self).__init__(*args, **kwargs)
with DAG(
dag_id='test_template_output',
start_date=datetime(2021, 10, 22),
schedule_interval='@daily',
catchup=False,
doc_md=__doc__,
) as dag:
TemplateOutputOperator(task_id='test_template_output_task')
```
Should generate
### Operating System
Official docker image
### Versions of Apache Airflow Providers
Default ones
### Deployment
Docker-Compose
### Deployment details
Here's my docker-compose and Dockerfile
```Dockerfile
FROM apache/airflow:2.2.3-python3.8
USER root
RUN apt-get update && apt-get install git -y
USER airflow
COPY requirements.txt .
RUN set -ex && pip install --user --requirement requirements.txt
```
```yaml
version: '3.9'
services:
airflow:
build: .
secrets:
- gcp_credentials.json
environment:
AIRFLOW__WEBSERVER__NAVBAR_COLOR: orange
AIRFLOW__WEBSERVER__EXPOSE_CONFIG: True
AIRFLOW__CORE__LOAD_DEFAULT_CONNECTIONS: False
GOOGLE_APPLICATION_CREDENTIALS: /run/secrets/gcp_credentials.json
command: standalone
volumes:
# mounts dags folder
- ./dags:/opt/airflow/dags
ports:
- "8080:8080"
```
### 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]