Skip to content

Connection password values appearing unmasked in the "Task Instance Details" -> "Environment" field #30089

@chriscmorgan

Description

@chriscmorgan

Apache Airflow version

Airflow 2.5.1

What happened

Connection password values appearing in the "Task Instance Details" -> "Task Attributes" -> environment field.

We are setting environment variables for the docker_operator with values from the password field in a connection.

The values from the password field are masked in the "Rendered Template" section and in the logs but it's showing the values in the "environment" field under Task Instance Details.

What you think should happen instead

These password values should be masked like they are in the "Rendered Template" and logs.

How to reproduce

Via this DAG, can run off any image.

Create a connection called "DATABASE_CONFIG" with a password in the password field.

Run this DAg and then check its Task Instance Details.

DAG Code:


from airflow import DAG
from docker.types import Mount
from airflow.providers.docker.operators.docker import DockerOperator
from datetime import timedelta
from airflow.models import Variable
from airflow.hooks.base_hook import BaseHook
import pendulum
import json

# Amount of times to retry job on failure
retries = 0

environment_config = {
    "DB_WRITE_PASSWORD": BaseHook.get_connection("DATABASE_CONFIG").password,
}

# Setup default args for the job
default_args = {
    "owner": "airflow",
    "start_date": pendulum.datetime(2023, 1, 1, tz="Australia/Sydney"),
    "retries": retries,
}

# Create the DAG
dag = DAG(
    "test_dag",  # DAG ID
    default_args=default_args,
    schedule_interval="* * * * *",  
    catchup=False,
)

# # Create the DAG object
with dag as dag:
    docker_task = DockerOperator(
        task_id="task",
        image="<image>",
        execution_timeout=timedelta(minutes=2),
        environment=environment_config,
        command="<command>",
        api_version="auto",
        docker_url="tcp://docker.for.mac.localhost:2375",
    )
    

Rendered Template is good:
image

In "Task Instance Details"
image

Operating System

centOS Linux and MAC

Versions of Apache Airflow Providers

No response

Deployment

Docker-Compose

Deployment details

Running on a docker via the airflow docker-compose

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions