dungdm93 opened a new issue #10913:
URL: https://github.com/apache/airflow/issues/10913


   **Apache Airflow version**:
   1.10.11
   
   **Environment**:
   
   - **Cloud provider or hardware configuration**: 
   - **OS** (e.g. from /etc/os-release): Ubuntu 20.04
   - **Kernel** (e.g. `uname -a`): 5.4.0-47-generic
   - **Install tools**:
   - **Others**:
   
   **What happened**:
   I store my connection into Airflow using this command
   ```bash
   $ airflow connections --add --conn_id=demo 
--conn_uri="http://localhost:8080/path/foo/bar";
   Successfully added `conn_id`=demo : http://localhost:8080/path/foo/bar
   ```
   
   And when It's used by hooks, I realize that HTTP connection parse path as 
schema but use as protocol:
   ```python
   from airflow.hooks.http_hook import HttpHook
   
   c = HttpHook.get_connection("demo")
   print(f"type={c.conn_type} schema={c.schema}, user={c.login}, 
pass={c.password}, host={c.host}, port={c.port}, extra={c.extra}")
   # type=http schema=path/foo/bar, user=user, pass=pass, host=localhost, 
port=8080, extra=None
   
   h = HttpHook(http_conn_id="demo")
   h.get_conn()
   print(h.base_url)
   # 'path/foo/bar://localhost:8080' 
   ```
   
   For now, I could workaround by store hold URI in host field like
   ```bash
   $ airflow connections --add --conn_id=demo2 --conn_type=http 
--conn_host=http://localhost:8080/path/foo/bar
   Successfully added `conn_id`=demo2 : 
http://:******@http://localhost:8080/path/foo/bar:
   ```
   But you could see, it's absolutely bad solution.
   
   So my suggestion is the connection should be sanitize follow the standard 
[URL 
syntax](https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Generic_syntax):
   
![image](https://user-images.githubusercontent.com/6848311/93023046-6906fb00-f616-11ea-9c87-20c9110942d4.png)
   
   This mean that:
   * `host` part should only contain domain name, hostname or IP address
   * rename `schema` filed to `path` for better naming. This filed store HTTP 
path or SQL database name
   * add `scheme` or `protocol` filed for store acture connection protocol, e.g:
       * https connection: `conn_type=http`, `protocol=https`
       * jdbc connection: `conn_type=mysql`, `protocol=jdbc:mysql`
   


----------------------------------------------------------------
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.

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


Reply via email to