0

I’m running my DAG with configuration JSON, which includes parameters which includes -, e.g. market-name When I’m trying to read it using the following Jinja template:

path_prefix = f"market={{{{ params.market-name }}}}/configuration"

I’m getting the following error:

jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'market'

It seems to me that Jinja doesn’t identify the full param name market-name but get the first part before the - which is market .

My questions:

  1. Does Jinja supports having - in the middle of a param (e.g. market-name) or should I avoid it from the beginning and use market_name instead?
  2. If Jinja doesn’t support having a - in the middle of a param
  • Should I escape the market-name ?
  • How should I escape it?
  1. Should I use {{ params.market-name }} instead of {{{{ params.market-name }}}}?
Yaron
  • 10,166
  • 9
  • 45
  • 65

1 Answers1

1

This is not Airflow bug. I reported it in this issue and this is a problem coming from Jinja/Python.

I could have not find any official documentation in Jinja that explains it but several reports mention that Jinja uses python interpreter's identifiers (see this answer and this answer). It might be best to report this issue to Jinja add documentation about it.

You can just avoid using -.

Elad Kalif
  • 14,110
  • 2
  • 17
  • 49