pdavis156879 opened a new issue #19158:
URL: https://github.com/apache/airflow/issues/19158


   ### Apache Airflow version
   
   2.1.3
   
   ### Operating System
   
   Ubuntu
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Docker-Compose
   
   ### Deployment details
   
   Deployed using official docker-compose image provided
   
   ### What happened
   
   Using Jinja templated arguments to add days to the execution_date via macros 
generates an error:
   
   ```
   [2021-10-22 11:59:32,965] {taskinstance.py:1462} ERROR - Task failed with 
exception
   Traceback (most recent call last):
     File 
"/home/airflow/.local/lib/python3.8/site-packages/airflow/models/taskinstance.py",
 line 1164, in _run_raw_task
       self._prepare_and_execute_task_with_callbacks(context, task)
     File 
"/home/airflow/.local/lib/python3.8/site-packages/airflow/models/taskinstance.py",
 line 1245, in _prepare_and_execute_task_with_callbacks
       self.render_templates(context=context)
     File 
"/home/airflow/.local/lib/python3.8/site-packages/airflow/models/taskinstance.py",
 line 1754, in render_templates
       self.task.render_template_fields(context)
     File 
"/home/airflow/.local/lib/python3.8/site-packages/airflow/models/baseoperator.py",
 line 997, 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 1010, in _do_render_template_fields
       rendered_content = self.render_template(content, context, jinja_env, 
seen_oids)
     File 
"/home/airflow/.local/lib/python3.8/site-packages/airflow/models/baseoperator.py",
 line 1064, in render_template
       return {key: self.render_template(value, context, jinja_env) for key, 
value in content.items()}
     File 
"/home/airflow/.local/lib/python3.8/site-packages/airflow/models/baseoperator.py",
 line 1064, in <dictcomp>
       return {key: self.render_template(value, context, jinja_env) for key, 
value in content.items()}
     File 
"/home/airflow/.local/lib/python3.8/site-packages/airflow/models/baseoperator.py",
 line 1047, in render_template
       return jinja_env.from_string(content).render(**context)
     File 
"/home/airflow/.local/lib/python3.8/site-packages/jinja2/environment.py", line 
941, in from_string
       return cls.from_code(self, self.compile(source), globals, None)
     File 
"/home/airflow/.local/lib/python3.8/site-packages/jinja2/environment.py", line 
638, in compile
       self.handle_exception(source=source_hint)
     File 
"/home/airflow/.local/lib/python3.8/site-packages/jinja2/environment.py", line 
832, in handle_exception
       reraise(*rewrite_traceback_stack(source=source))
     File "/home/airflow/.local/lib/python3.8/site-packages/jinja2/_compat.py", 
line 28, in reraise
       raise value.with_traceback(tb)
     File "<unknown>", line 1, in template
   jinja2.exceptions.TemplateSyntaxError: unexpected ')'
   ```
   
   ### What you expected to happen
   
   The execution date to be incremented by one day
   
   ### How to reproduce
   
   ```
   def print_dates(execution_date, execution_date_incremented):
       print('----------')
       print('Execution Date:', execution_date)
       print('Execution Date Incremented:', execution_date_incremented)
   
   with DAG(
           dag_id='test_dag', 
           default_args=default_args, 
           schedule_interval= '0 * * * *',
           catchup=False
       ) as dag:
   
       start_point = PythonOperator(
           task_id='print_current_date',
           python_callable = print_dates,
           op_kwargs={'execution_date': "{{ ds }}", 
'execution_date_incremented': "{{ macros.ds_add(ds, -5) }}"},
       )
   ```
   
   ### 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]


Reply via email to