Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAG fails with "can only concatenate str (not 'Variable') to str" error when triggered using astro run command #1791

Open
2 tasks
kandharvishnu opened this issue Jan 30, 2025 · 0 comments

Comments

@kandharvishnu
Copy link

kandharvishnu commented Jan 30, 2025

Describe the bug

When a DAG is triggered using the astro run <dag_id> command and variable imported from airflow_settings.yaml, it fails with the error:

FAILED ❌ can only concatenate str (not "Variable") to str.

However, the same DAG runs successfully when triggered from the Airflow UI or using the airflow dags trigger <dag_id> command.

What CLI Version did you experience this bug?
1.30.0

This CLI bug is related to which Astronomer Platform?

  • [ X ] Astro
  • Software
  • None/Unknown

What Operating System is the above CLI installed on?

🪜 Steps To Reproduce

  • Add a variable in airflow_settings.yaml.
  • Use the variable in a DAG task. For example:
from airflow import DAG
from airflow.operators.python import PythonOperator
from datetime import datetime

# Define the Python function to be executed
def read_variable():
    from airflow.models import Variable
    bucket_name = Variable.get("default_s3_bucket")
    print('*' + bucket_name + '*')

# Default arguments for the DAG
default_args = {
    'owner': 'airflow',
    'retries': 1,
}

# Instantiate the DAG
with DAG(
    dag_id='simple_python_operator_dag',
    default_args=default_args,
    start_date=datetime(2024, 1, 1),
    schedule_interval='@daily',  # Runs daily
    catchup=False,
) as dag:

    read_variable = PythonOperator(
        task_id="read_variable",
        python_callable=read_variable
    )
  • Trigger the DAG using the astro run <dag_id> command from the local environment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant