PCTEJA commented on code in PR #77376:
URL: https://github.com/apache/airflow/pull/77376#discussion_r4702060847
##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/fs/adls.py:
##########
@@ -77,8 +96,32 @@ def get_fs(conn_id: str | None, storage_options: dict[str,
Any] | None = None) -
# is the storage account name rather than part of an account URL.
options["account_name"] = account_name
elif conn_type != "adls" or conn.host or not tenant_id:
- # WASB, full-URL, and custom-endpoint connections keep the historical
account_url path.
- options["account_url"] = parse_blob_account_url(conn.host, conn.login)
+ # adlfs has no account_url parameter and would silently drop it; it
reads
+ # account_name and builds the URL from account_host, so derive both
from
+ # the host. Only an endpoint host (a hostname with a dot, the same
+ # parsing _bare_account_name_from_host uses) supplies an account_host,
+ # and only when it is not the default blob host, which adlfs already
+ # defaults to. The name and host come from the parsed hostname, not the
+ # rebuilt account URL: parse_blob_account_url misreads a host with a
+ # port and no scheme as a scheme, and would build the URL from the
+ # login instead. A bare identifier is not an endpoint, and for those
+ # parse_blob_account_url builds the URL from the login. A bare login is
+ # the account name (wasb shared key), but with a tenant id the login
is a
+ # service principal client id, so without an endpoint host nothing is
+ # derived and adlfs falls back to account_name from extras or the
+ # AZURE_STORAGE_ACCOUNT_NAME env var.
+ conn_hostname = _hostname_from_host(conn.host)
+ host_is_endpoint = conn_hostname is not None and "." in conn_hostname
+ if host_is_endpoint:
+ derived_account_name = conn_hostname.split(".")[0]
Review Comment:
Fixed in 3e7d0088: direct hostname check narrows the type for mypy.
##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/fs/adls.py:
##########
@@ -30,22 +30,41 @@
schemes = ["abfs", "abfss", "adl"]
+def _hostname_from_host(host: str | None) -> str | None:
+ if not host:
+ return None
+ return urlparse(host if "://" in host else f"//{host}").hostname
+
+
+def _account_host_from_host(host: str | None) -> str | None:
+ if not host:
+ return None
+ parsed = urlparse(host if "://" in host else f"//{host}")
Review Comment:
Fixed at 3e7d0088: shared parse helper raises ValueError for invalid ports.
--
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]