Skip to content

Improve confirmation output when connections are added via cli - #71215

Merged
potiuk merged 1 commit into
apache:mainfrom
astronomer:fix-connections-create-display
Aug 7, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
astronomer:fix-connections-create-display

Conversation

@amoghrajesh

Copy link
Copy Markdown
Contributor

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Why and What?

The success message reconstructed a URI from login/host/port even when those fields were never set, producing a misleading aws://:@: and never showing what was actually stored in extra. Replace it with a table (reusing the CLI's existing table renderer) that shows the fields that were actually set, with extra passed through the shared secrets masker so sensitive keys are redacted per-key instead of the confirmation omitting extra entirely.

Testing

To test, created this script:

#!/usr/bin/env bash
# Demo script for the new `airflow connections add` confirmation output.
# Run via breeze from the repo root:
#   breeze run bash dev/demo_connections_add.sh
set -euo pipefail

CONN_IDS=(
  demo_aws_extra_only
  demo_aws_with_secret
  demo_postgres_uri
  demo_generic_discrete
  demo_generic_json
)

cleanup() {
  for conn_id in "${CONN_IDS[@]}"; do
    airflow connections delete "$conn_id" >/dev/null 2>&1 || true
  done
}
trap cleanup EXIT

cleanup

echo "=== 1. Extra-only AWS connection (no host/login/password) ==="
airflow connections add demo_aws_extra_only \
  --conn-type aws \
  --conn-extra '{"region_name": "us-east-1"}'

echo
echo "=== 2. AWS connection with a sensitive key in extra (gets redacted) ==="
airflow connections add demo_aws_with_secret \
  --conn-type aws \
  --conn-extra '{"region_name": "us-east-1", "aws_secret_access_key": "supersecretvalue"}'

echo
echo "=== 3. Postgres connection via --conn-uri ==="
airflow connections add demo_postgres_uri \
  --conn-uri 'postgresql://airflow:airflow@localhost:5432/airflow'

echo
echo "=== 4. Generic connection via discrete flags ==="
airflow connections add demo_generic_discrete \
  --conn-type generic \
  --conn-host example.com \
  --conn-login myuser \
  --conn-port 443

echo
echo "=== 5. Connection via --conn-json with nested extra ==="
airflow connections add demo_generic_json \
  --conn-json '{"conn_type": "generic", "host": "example.com", "extra": {"api_key": "shouldberedacted", "region": "eu-west-1"}}'

Output:

[Breeze:3.10.20] root@4f2541c6e55f:/opt/airflow$  bash dev/demo_connections_add.sh
=== 1. Extra-only AWS connection (no host/login/password) ===
Successfully added `conn_id`=demo_aws_extra_only
conn_id             | conn_type | host | login | port | extra
====================+===========+======+=======+======+=============================
demo_aws_extra_only | aws       | None | None  | None | {'region_name': 'us-east-1'}


=== 2. AWS connection with a sensitive key in extra (gets redacted) ===
Successfully added `conn_id`=demo_aws_with_secret
conn_id              | conn_type | host | login | port | extra
=====================+===========+======+=======+======+=============================================================
demo_aws_with_secret | aws       | None | None  | None | {'region_name': 'us-east-1', 'aws_secret_access_key': '***'}


=== 3. Postgres connection via --conn-uri ===
Successfully added `conn_id`=demo_postgres_uri
conn_id           | conn_type | host      | login   | port | extra
==================+===========+===========+=========+======+======
demo_postgres_uri | postgres  | localhost | airflow | 5432 | {}


=== 4. Generic connection via discrete flags ===
Successfully added `conn_id`=demo_generic_discrete
conn_id               | conn_type | host        | login  | port | extra
======================+===========+=============+========+======+======
demo_generic_discrete | generic   | example.com | myuser | 443  | {}


=== 5. Connection via --conn-json with nested extra ===
Successfully added `conn_id`=demo_generic_json
conn_id           | conn_type | host        | login | port | extra
==================+===========+=============+=======+======+==========================================
demo_generic_json | generic   | example.com | None  | None | {'api_key': '***', 'region': 'eu-west-1'}

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@potiuk
potiuk merged commit 5ed6f8f into apache:main Aug 7, 2026
72 checks passed
potiuk pushed a commit that referenced this pull request Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants