eladkal opened a new issue #8688: URL: https://github.com/apache/airflow/issues/8688
**What happened**: Defined variable as:  Trying to access the variable via: `{{ var.json.csba-catalog.sandbox }}` Gives: ``` Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/airflow/models/__init__.py", line 1426, in _run_raw_task self.render_templates() File "/usr/local/lib/python3.6/site-packages/airflow/models/__init__.py", line 1790, in render_templates rendered_content = rt(attr, content, jinja_context) File "/usr/local/lib/python3.6/site-packages/airflow/models/__init__.py", line 2538, in render_template return self.render_template_from_field(attr, content, context, jinja_env) File "/usr/local/lib/python3.6/site-packages/airflow/models/__init__.py", line 2514, in render_template_from_field result = jinja_env.from_string(content).render(**context) File "/usr/local/lib/python3.6/site-packages/jinja2/asyncsupport.py", line 76, in render return original_render(self, *args, **kwargs) File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 1008, in render return self.environment.handle_exception(exc_info, True) File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 780, in handle_exception reraise(exc_type, exc_value, tb) File "/usr/local/lib/python3.6/site-packages/jinja2/_compat.py", line 37, in reraise raise value.with_traceback(tb) File "<template>", line 1, in top-level template code File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 430, in getattr return getattr(obj, attribute) File "/usr/local/lib/python3.6/site-packages/airflow/models/__init__.py", line 1728, in __getattr__ self.var = Variable.get(item, deserialize_json=True) File "/usr/local/lib/python3.6/site-packages/airflow/utils/db.py", line 73, in wrapper return func(*args, **kwargs) File "/usr/local/lib/python3.6/site-packages/airflow/models/__init__.py", line 4368, in get raise KeyError('Variable {} does not exist'.format(key)) KeyError: 'Variable csba does not exist' ``` Trying to access with: `catalog_variable = Variable.get("csba-catalog", deserialize_json=True)` works. **How to reproduce it:** ``` from airflow.operators.bash_operator import BashOperator catalog_variable = Variable.get("csba-catalog", deserialize_json=True) catalog= catalog_variable["sandbox"] default_args = { 'owner': 'airflow', 'depends_on_past': False, 'start_date': datetime(2019, 6, 25), } with DAG( dag_id="reproduce_bug", default_args=default_args, schedule_interval=None, max_active_runs=1, catchup=False ) as dag: t1 = BashOperator( task_id='jinja', bash_command='echo {{ var.json.csba-catalog.sandbox }}', dag=dag, ) t2 = BashOperator( task_id='variable_get', bash_command=f'echo {catalog}', dag=dag, ) ``` Gives: **task_id='jinja':**  **task_id='variable_get':**  **more info:** If I remove the hyphen:  Both works. **Required fix** It should work in both cases. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
