title: Airflow how to set default values for dag_run.conf
body: <p>I'm trying to setup an Airflow DAG that provides default values available from <code>dag_run.conf</code>. This works great when running the DAG from the webUI, using the &quot;Run w/ Config&quot; option. However when running on the schedule, the <code>dag_run.conf</code> dict is not present, and the task will fail, e.g.</p>
  <pre><code>jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'key1'
  </code></pre>
  <p>Below is an example job.</p>
  <p>Is it possible to make it so that <code>dag_run.conf</code> always contains the dict defined by <code>params</code> here?</p>
  <pre class="lang-py prettyprint-override"><code>from airflow import DAG
  from airflow.utils.dates import hours_ago
  from airflow.operators.bash import BashOperator
  from datetime import timedelta
  
  def do_something(val1: str, val2: str) -&gt; str:
      return f'echo vars are: &quot;{val1}, {val2}&quot;'
  
  params = {
      'key1': 'def1',
      'key2': 'def2',        
  }
  
  default_args = {
      'retries': 0,
  }
  
  with DAG(
      'template_test',
      default_args=default_args,
      schedule_interval=timedelta(minutes=1),
      start_date=hours_ago(1),
      params = params,
  ) as dag:
  
      hello_t = BashOperator(
          task_id='example-command',
          bash_command=do_something('{{dag_run.conf[&quot;key1&quot;]}}', '{{dag_run.conf[&quot;key2&quot;]}}'),
          config=params,
      )
  </code></pre>
  <p>The closest I've seen is in <a href="https://stackoverflow.com/questions/53663534/for-apache-airflow-how-can-i-pass-the-parameters-when-manually-trigger-dag-via/53686174#53686174">For Apache Airflow, How can I pass the parameters when manually trigger DAG via CLI?</a>, however there they leverage Jinja and if/else - which would require defining these default parameters twice. I'd like to define them only once.</p>