You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/09/26 11:26:08 UTC

[GitHub] [airflow] mrn-aglic commented on issue #24388: Unable to access operator attrs within Jinja context for mapped tasks

mrn-aglic commented on issue #24388:
URL: https://github.com/apache/airflow/issues/24388#issuecomment-1257885521

   The proposed workaround: `SELECT * FROM {{ task.mapped_kwargs.parameters[ti.map_index].tbl }};`
   Doesn't seem to be working on **airflow 2.4.0**. 
   I get the following exception:
   
   
   ```
   Traceback (most recent call last):
     File "/home/airflow/.local/lib/python3.9/site-packages/airflow/models/abstractoperator.py", line 410, in _do_render_template_fields
       rendered_content = self.render_template(
     File "/home/airflow/.local/lib/python3.9/site-packages/airflow/models/abstractoperator.py", line 474, in render_template
       return render_template_to_string(template, context)
     File "/home/airflow/.local/lib/python3.9/site-packages/airflow/utils/helpers.py", line 288, in render_template_to_string
       return render_template(template, cast(MutableMapping[str, Any], context), native=False)
     File "/home/airflow/.local/lib/python3.9/site-packages/airflow/utils/helpers.py", line 283, in render_template
       return "".join(nodes)
     File "<template>", line 14, in root
     File "/home/airflow/.local/lib/python3.9/site-packages/jinja2/sandbox.py", line 326, in getattr
       value = getattr(obj, attribute)
     File "/home/airflow/.local/lib/python3.9/site-packages/jinja2/runtime.py", line 859, in __getattr__
       return self._fail_with_undefined_error()
     File "/home/airflow/.local/lib/python3.9/site-packages/jinja2/runtime.py", line 852, in _fail_with_undefined_error
       raise self._undefined_exception(self._undefined_message)
   jinja2.exceptions.UndefinedError: '***.models.mappedoperator.MappedOperator object' has no attribute 'mapped_kwargs'
   [2022-09-26, 11:23:52 UTC] {taskinstance.py:1851} ERROR - Task failed with exception
   Traceback (most recent call last):
     File "/home/airflow/.local/lib/python3.9/site-packages/airflow/models/taskinstance.py", line 1457, in _run_raw_task
       self._execute_task_with_callbacks(context, test_mode)
     File "/home/airflow/.local/lib/python3.9/site-packages/airflow/models/taskinstance.py", line 1576, in _execute_task_with_callbacks
       task_orig = self.render_templates(context=context)
     File "/home/airflow/.local/lib/python3.9/site-packages/airflow/models/taskinstance.py", line 2193, in render_templates
       rendered_task = self.task.render_template_fields(context)
     File "/home/airflow/.local/lib/python3.9/site-packages/airflow/models/mappedoperator.py", line 764, in render_template_fields
       self._do_render_template_fields(
     File "/home/airflow/.local/lib/python3.9/site-packages/airflow/utils/session.py", line 72, in wrapper
       return func(*args, **kwargs)
     File "/home/airflow/.local/lib/python3.9/site-packages/airflow/models/abstractoperator.py", line 410, in _do_render_template_fields
       rendered_content = self.render_template(
     File "/home/airflow/.local/lib/python3.9/site-packages/airflow/models/abstractoperator.py", line 474, in render_template
       return render_template_to_string(template, context)
     File "/home/airflow/.local/lib/python3.9/site-packages/airflow/utils/helpers.py", line 288, in render_template_to_string
       return render_template(template, cast(MutableMapping[str, Any], context), native=False)
     File "/home/airflow/.local/lib/python3.9/site-packages/airflow/utils/helpers.py", line 283, in render_template
       return "".join(nodes)
     File "<template>", line 14, in root
     File "/home/airflow/.local/lib/python3.9/site-packages/jinja2/sandbox.py", line 326, in getattr
       value = getattr(obj, attribute)
     File "/home/airflow/.local/lib/python3.9/site-packages/jinja2/runtime.py", line 859, in __getattr__
       return self._fail_with_undefined_error()
     File "/home/airflow/.local/lib/python3.9/site-packages/jinja2/runtime.py", line 852, in _fail_with_undefined_error
       raise self._undefined_exception(self._undefined_message)
   jinja2.exceptions.UndefinedError: '***.models.mappedoperator.MappedOperator object' has no attribute 'mapped_kwargs'
   
   ```


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org