** Description **
When a new operator is defined there are some issues with template_fields that produces somewhat misleading error messages
template_fields = ('myfield'), which of course is incorrect because that is not a tuple, you need to use ('myfield',) or ['myfield']
template_field = ['field_with_a_typo']
As a I said both gives errors (at different stages) but the errors are a bit cryptic
For example:
[2020-12-07 09:50:45,088] {taskinstance.py:1150} ERROR - 'SFTPToS3Operator2' object has no attribute 's3_key'
Traceback (most recent call last):
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 965, in _run_raw_task
self.render_templates(context=context)
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1424, in render_templates
self.task.render_template_fields(context)
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/baseoperator.py", line 719, in render_template_fields
self._do_render_template_fields(self, self.template_fields, context, jinja_env, set())
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/baseoperator.py", line 724, in _do_render_template_fields
content = getattr(parent, attr_name)
AttributeError: 'SFTPToS3Operator2' object has no attribute 's3_key'
where there is no mention that this is related to templated_fields
Use case / motivation
In order to have a better experience developing plugins I would like
- A warning / error if a str is used for
template_fields = 'myfield'. It's very unlikely that anyone want to use myfield as sequence ['m','y', 'f','i','e','l','d'].
- A more specific error message in
_run_raw_task if template_fields contains attributes not present.
Description
Use case / motivation
Related Issues
** Description **
When a new operator is defined there are some issues with
template_fieldsthat produces somewhat misleading error messagestemplate_fields = ('myfield'), which of course is incorrect because that is not a tuple, you need to use('myfield',)or['myfield']template_field = ['field_with_a_typo']As a I said both gives errors (at different stages) but the errors are a bit cryptic
For example:
where there is no mention that this is related to
templated_fieldsUse case / motivation
In order to have a better experience developing plugins I would like
template_fields = 'myfield'. It's very unlikely that anyone want to usemyfieldas sequence['m','y', 'f','i','e','l','d']._run_raw_taskiftemplate_fieldscontains attributes not present.Description
Use case / motivation
Related Issues