Airflow has an annoying error that causes a failure when we try to use the BashOperator like this:

Table of Contents

  1. Get Weekly AI Implementation Insights

operator = BashOperator(
    task_id='operator_id',
    bash_command='some_bash_script.sh',
    dag=dag)

What is wrong? For some reason, it tries to apply the template variables to the “bash_command” parameter even if we don’t use them. Consequently, the template loader fails with the TemplateNotFound error because it cannot find any template variables in the given string.

Of course, in this case, it is the correct behavior because we don’t use any template variables. Unfortunately, it is not the behavior we want.

To make Airflow ignore the missing template and just use the given string as the file name (as it should do anyway), we have to trick the template parsing code by adding a single space at the end of the parameter:

operator = BashOperator(
    task_id='operator_id',
    bash_command='some_bash_script.sh ',
    dag=dag)

Get Weekly AI Implementation Insights

Join engineering leaders who receive my analysis of common AI production failures and how to prevent them. No fluff, just actionable techniques.

Get Weekly AI Implementation Insights

Join engineering leaders who receive my analysis of common AI production failures and how to prevent them. No fluff, just actionable techniques.

Older post

Copy directories in S3 using s3-dist-cp

How to copy files in S3 and preserve the directory structure

Newer post

How to use xcom_pull to get a variable from another DAG

Get an XCOM variable from another DAG

Engineering leaders: Is your AI failing in production? Take the 10-minute assessment
>