In 2.0.0b2/master, CLI "airflow connections add" is not handling invalid URIs properly
See original GitHub issueApache Airflow version: 2.0.0b2
Environment: Docker
- Cloud provider or hardware configuration:
- OS (e.g. from /etc/os-release):
- Kernel (e.g.
uname -a): - Install tools:
- Others:
What happened:
In current 2.0.0b2, airflow connections add is not handling invalid URIs properly.
For example, running CLI airflow connections add --conn-uri xyz conn_dummy will
- create the connection “conn_dummy” successfully (which should not be, IMO)
- in the connection created, it only has one attribute filled, which is “schema”, but the value added is “yz” (the value we provide is “xyz”, i.e., the 1st element is removed. because of https://github.com/apache/airflow/blob/master/airflow/models/connection.py#L213)
What you expected to happen:
In my opinion, a validation should be done first to ensure the conn-uri provided is valid (at least have “scheme” and “netloc” available in the urlparse result), and reject if it’s an invalid URI.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Managing Connections — Airflow ... - Apache Airflow
Connections defined in environment variables will not show up in the Airflow UI or using airflow ... You may add a connection to...
Read more >Manage connections in Apache Airflow - Astronomer Docs
This guide focuses on adding connections using the Airflow UI and environment variables. For more in-depth information on configuring connections using ...
Read more >Adding a connection to Airflow via command line for hive_cli ...
Commandline reports success but the Conn Type is not set correctly in the Airflow UI and connection wont work. I think the error...
Read more >Managing Airflow connections | Cloud Composer
Airflow connections enable you to access resources in Google Cloud projects from a Cloud Composer environment. You create Airflow connection IDs to store ......
Read more >Secrets Management in Airflow 2.0 - YouTube
Learn about Secrets Management and best practices in Airflow 2.0.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@XD-DENG @kaxil I’m not sure if an error should be raised on a missing
netlocsince at least for Google Cloud connections it’s actually ignored: https://airflow.apache.org/docs/apache-airflow-providers-google/stable/connections/gcp.html#configuring-the-connectionThis caused a regression for us when upgrading to Airflow 2 and setting up connections through the CLI. It took me a while to figure out what was causing the URI to become “invalid” - so this at least there should be a more precise warning about the actual part missing…
Oh yes it should definitely raise an error