dabla commented on code in PR #77376:
URL: https://github.com/apache/airflow/pull/77376#discussion_r4655166780
##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/fs/adls.py:
##########
@@ -77,8 +80,46 @@ 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 account URL. 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: 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 or (conn.login and not tenant_id):
+ account_url = urlparse(parse_blob_account_url(conn.host,
conn.login))
Review Comment:
**[nit]** A host with a port and no scheme, on a connection without a login,
yields the account `none`.
`urlparse("acct.blob.core.windows.net:443")` reads the host as the scheme,
so `parse_blob_account_url` finds no netloc and builds the URL from the login,
which is `None` here. On `main` that connection raised adlfs's `ValueError`; on
this head `get_fs` returns a filesystem with `account_name="none"` and
`account_url="https://none.blob.core.windows.net"` (run against adlfs
2026.8.0). With a login set the same host works. `_hostname_from_host` already
parses this host correctly, so the account name could come from `conn_hostname`
when the host is an endpoint, instead of from the rebuilt URL.
##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/fs/adls.py:
##########
@@ -77,8 +80,46 @@ 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 account URL. 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: 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 or (conn.login and not tenant_id):
+ account_url = urlparse(parse_blob_account_url(conn.host,
conn.login))
+ derived_account_name = account_url.hostname.split(".")[0] if
account_url.hostname else None
+ if derived_account_name:
+ options["account_name"] = derived_account_name
+ if host_is_endpoint and account_url.netloc:
+ # adlfs is a Blob client, so an Azure Data Lake (dfs) endpoint
is
+ # mapped back to its blob form before it can become the
+ # account_host. Only a standard Azure endpoint is mapped (a dfs
+ # label in front of a core label and an Azure suffix); a custom
+ # domain is kept as is. The host is lowercased first, as
+ # hostnames are case-insensitive and urlparse only lowercases
+ # .hostname, and an explicit port is carried over unchanged.
+ netloc_host, colon, netloc_port =
account_url.netloc.lower().rpartition(":")
+ if not colon or not netloc_port.isdigit():
+ netloc_host, netloc_port = account_url.netloc.lower(), ""
+ account_host_labels = netloc_host.split(".")
+ if account_host_labels[1:3] == ["dfs", "core"] and
".".join(account_host_labels[3:]) in {
Review Comment:
**[nit]** The `dfs` mapping matches on label position and a fixed suffix
list, so two real endpoint shapes stay on the Data Lake endpoint.
On this head, with a service principal:
| Host | `fs.account_url` |
| --- | --- |
| `acct.dfs.core.windows.net` | `https://acct.blob.core.windows.net` |
| `acct.dfs.core.usgovcloudapi.net` |
`https://acct.blob.core.usgovcloudapi.net` |
| `acct.privatelink.dfs.core.windows.net` |
`https://acct.privatelink.dfs.core.windows.net` |
| `acct.dfs.core.<a cloud not in the set>` | unchanged, still `dfs` |
`dfs` is the third label on a private-link name, and the suffix set will age
as clouds are added. Replacing `.dfs.core.` by `.blob.core.` anywhere in the
hostname covers both without a list; the only case it changes is a custom
domain that itself contains `.dfs.core.`. Separately, lines 109-111 split host
and port by hand where `account_url.hostname` (already lowercased) and
`account_url.port` give the same two values, and the whole block would read
better as a small helper next to `_hostname_from_host` than inline in `get_fs`.
--
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]