You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "potiuk (via GitHub)" <gi...@apache.org> on 2023/08/10 17:41:26 UTC

[GitHub] [airflow] potiuk commented on a diff in pull request #33289: Fix urlparse schemaless-behaviour on Python 3.9+

potiuk commented on code in PR #33289:
URL: https://github.com/apache/airflow/pull/33289#discussion_r1290471842


##########
airflow/providers/elasticsearch/log/es_task_handler.py:
##########
@@ -143,7 +143,9 @@ def format_url(host: str) -> str:
         parsed_url = urlparse(host)
 
         # Check if the scheme is either http or https
-        if not parsed_url.scheme:
+        # the second condition handles the Python 3.9+ case where urlparse understands "localhost:9200"
+        # differently than urlparse in Python 3.8 and below (https://github.com/psf/requests/issues/6455)
+        if not parsed_url.scheme or (parsed_url.scheme not in ("http", "https") and not parsed_url.netloc):

Review Comment:
   Yes. On Python 3.9 "localhost:9002" parses to :+1: 
   * schema="localhost"
   * netloc=""
   
   This is why the tests started to fail in main and according to https://github.com/psf/requests/issues/6455 this is expected behaviour :). Don't ask me why - but it is (read the discussion there, it's entertaining).
   



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org