You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Julian Vasilkoski (Jira)" <ji...@apache.org> on 2020/01/04 01:57:00 UTC

[jira] [Created] (AIRFLOW-6448) Connection URI Parsing Swaps Service and Scheme Components

Julian Vasilkoski created AIRFLOW-6448:
------------------------------------------

             Summary: Connection URI Parsing Swaps Service and Scheme Components
                 Key: AIRFLOW-6448
                 URL: https://issues.apache.org/jira/browse/AIRFLOW-6448
             Project: Apache Airflow
          Issue Type: Bug
          Components: configuration, hooks
    Affects Versions: 1.10.7
         Environment: python:3.7-alpine3.10 Docker image ran on Kubernetes cluster using Kubernetes Executor.
            Reporter: Julian Vasilkoski
             Fix For: 2.0.0


This issue was discovered when specifying a Slack connection as a URI via an environment variable.

Using the following connection definition via environment variable:
{code:java}
AIRFLOW_CONN_SLACKCONN=https://hooks.slack.com/services?webhook_token=MYAWESOMETOKEN
{code}
results in the following error:
{code:java}
{"asctime": "2020-01-04 01:44:56,748", "filename": "logging_mixin.py", "lineno": 112, "levelname": "INFO", "message": "[2020-01-04 01:44:56,748] {http_hook.py:131} INFO - Sending 'POST' to url: services://hooks.slack.com/MYAWESOMETOKEN", "dag_id": "mydagid", "task_id": "notify", "execution_date": "2020_01_04T01_44_47_230593", "try_number": "1"}
{code}
i.e. the final URL generated by Airflow is:
{code:java}
services://hooks.slack.com/MYAWESOMETOKEN
{code}
The issue seems to be in:

[airflow/models/connection.py|https://github.com/apache/airflow/blob/c8597cbf143b970ad3c7b0d62e3b44d1dfdc8afe/airflow/models/connection.py]

Specifically:
{code:java}
    def parse_from_uri(self, uri):
                uri_parts = urlparse(uri)
                conn_type = uri_parts.scheme
                if conn_type == 'postgresql':
                    conn_type = 'postgres'
                elif '-' in conn_type:
                    conn_type = conn_type.replace('-', '_')
                self.conn_type = conn_type
                self.host = parse_netloc_to_hostname(uri_parts)
                quoted_schema = uri_parts.path[1:]
                self.schema = unquote(quoted_schema) if quoted_schema else quoted_schema
                self.login = unquote(uri_parts.username) \
                    if uri_parts.username else uri_parts.username
                self.password = unquote(uri_parts.password) \
                    if uri_parts.password else uri_parts.password
                self.port = uri_parts.port
                if uri_parts.query:
                    self.extra = json.dumps(dict(parse_qsl(uri_parts.query, keep_blank_values=True)))
{code}
A hacky workaround for this particular case is to define AIRFLOW_CONN_SLACKCONN as:
{code:java}
services://hooks.slack.com/https?webhook_token=/services/MYAWESOMETOKEN
{code}
 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)