amoghrajesh opened a new pull request, #71215:
URL: https://github.com/apache/airflow/pull/71215

    <!-- SPDX-License-Identifier: Apache-2.0
         https://www.apache.org/licenses/LICENSE-2.0 -->
   
   <!--
   Thank you for contributing!
   
   Please provide above a brief description of the changes made in this pull 
request.
   Write a good git commit message following this guide: 
https://chris.beams.io/posts/git-commit/
   
   Please make sure that your code changes are covered with tests.
   And in case of new features or big changes remember to adjust the 
documentation.
   
   For user-facing UI changes, please attach before/after screenshots (or a 
short
   screen recording) so reviewers can assess the visual impact.
   
   Feel free to ping (in general) for the review if you do not see reaction for 
a few days
   (72 Hours is the minimum reaction time you can expect from volunteers) - we 
sometimes miss notifications.
   
   In case of an existing issue, reference it using one of the following:
   
   * closes: #ISSUE
   * related: #ISSUE
   -->
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   <!--
   If generative AI tooling has been used in the process of authoring this PR, 
please
   change below checkbox to `[X]` followed by the name of the tool, uncomment 
the "Generated-by".
   -->
   
   - [ ] Yes (please specify the tool below)
   
   <!--
   Generated-by: [Tool Name] following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   -->
   
   ## 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:
   ```shell
   #!/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:
   
   ```shell
   [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](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#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](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
 is needed.
   * When adding dependency, check compliance with the [ASF 3rd Party License 
Policy](https://www.apache.org/legal/resolved.html#category-x).
   * For significant user-facing changes create newsfragment: 
`{pr_number}.significant.rst`, in 
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
 You can add this file in a follow-up commit after the PR is created so you 
know the PR number.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to