kaxil commented on code in PR #77788:
URL: https://github.com/apache/airflow/pull/77788#discussion_r4746733874


##########
providers/samba/src/airflow/providers/samba/fs/smb.py:
##########
@@ -0,0 +1,54 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from typing import TYPE_CHECKING, Any
+
+from airflow.providers.common.compat.sdk import BaseHook
+
+if TYPE_CHECKING:
+    from fsspec import AbstractFileSystem
+
+schemes = ["smb"]
+
+
+def get_fs(conn_id: str | None, storage_options: dict[str, Any] | None = None) 
-> AbstractFileSystem:
+    # Imported here so that discovering filesystems does not load smbclient in 
every process.
+    from airflow.providers.samba.fs._smb_filesystem import 
_IsolatedSMBFileSystem
+    from airflow.providers.samba.hooks.samba import _get_auth_protocol
+
+    if conn_id is None:
+        manual_options = storage_options or {}
+        if not manual_options.get("host"):
+            raise ValueError(
+                "An SMB path needs a connection id, for example 
smb://my_conn@/share/path/to/file."
+            )
+        return _IsolatedSMBFileSystem(**manual_options)
+
+    conn = BaseHook.get_connection(conn_id)
+    options: dict[str, Any] = {

Review Comment:
   Should `auto_mkdir` default to `True` here? `ObjectStoragePath.copy` from 
GCS into an SMB folder opens `dst / self.key` for writing without creating the 
key's parent folders, so a source key like `data/a.csv` fails on the share. And 
a path has no way to turn it on, since `ObjectStore.fs` calls `get_fs` without 
`storage_options`.



##########
providers/samba/tests/unit/samba/fs/test__smb_filesystem.py:
##########
@@ -0,0 +1,144 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import stat
+from unittest import mock
+
+import pytest
+import smbclient
+from smbclient._os import SMBStatResult
+
+from airflow.providers.samba.fs._smb_filesystem import _IsolatedSMBFileSystem, 
_SMBFileOpener
+
+SMBCLIENT_FUNCTIONS = (
+    "copyfile",
+    "listdir",
+    "makedirs",
+    "open_file",
+    "remove",
+    "rename",
+    "replace",
+    "rmdir",
+    "stat",
+)
+
+
+def make_stat(mode: int) -> SMBStatResult:
+    return SMBStatResult._make([0] * 
len(SMBStatResult._fields))._replace(st_mode=mode)
+
+
[email protected]
+def mock_smbclient():
+    """Replace the smbclient calls that fsspec and the filesystem make, with a 
regular file for ``stat``."""
+    with mock.patch.multiple(
+        smbclient, autospec=True, **dict.fromkeys(SMBCLIENT_FUNCTIONS, 
mock.DEFAULT)
+    ) as m:
+        m["stat"].return_value = make_stat(stat.S_IFREG)
+        yield m
+
+
+def make_fs() -> _IsolatedSMBFileSystem:
+    return _IsolatedSMBFileSystem(
+        host="testhost",
+        username="testuser",
+        password="testpass",
+        encrypt=True,
+        timeout=30,
+        skip_instance_cache=True,
+    )
+
+
+def assert_sends_session(call: mock._Call, fs: _IsolatedSMBFileSystem) -> None:
+    assert call.kwargs["username"] == "testuser"
+    assert call.kwargs["password"] == "testpass"
+    assert call.kwargs["port"] == 445
+    assert call.kwargs["encrypt"] is True
+    assert call.kwargs["connection_timeout"] == 30
+    assert call.kwargs["auth_protocol"] == "negotiate"
+    assert call.kwargs["connection_cache"] is fs._connection_cache
+
+
+class TestAirflowSMBFileSystem:
+    @mock.patch.object(smbclient, "register_session", autospec=True)
+    def test_does_not_connect_on_construction(self, mock_register_session):
+        make_fs()
+
+        mock_register_session.assert_not_called()
+
+    @pytest.mark.parametrize(
+        ("method", "args", "smbclient_function"),
+        [
+            pytest.param("ls", ("/share/dir", False), "listdir", id="ls"),
+            pytest.param("info", ("/share/a.csv",), "stat", id="info"),
+            pytest.param("created", ("/share/a.csv",), "stat", id="created"),
+            pytest.param("modified", ("/share/a.csv",), "stat", id="modified"),
+            pytest.param("mkdir", ("/share/new",), "makedirs", id="mkdir"),
+            pytest.param("makedirs", ("/share/new",), "makedirs", 
id="makedirs"),
+            pytest.param("rmdir", ("/share/old",), "rmdir", id="rmdir"),
+            pytest.param("_rm", ("/share/a.csv",), "remove", id="rm"),

Review Comment:
   This only covers `_rm` on a file, so the directory arm (the `rmdir` call) 
could drop the session and nothing would fail. The `auto_mkdir` blocks in 
`cp_file` and in both `_open` branches aren't covered either, and 
`created`/`modified` are only checked for their call kwargs, so swapping 
`st_ctime` and `st_mtime` still passes. Could you add an `S_IFDIR` case for 
`_rm`, `auto_mkdir=True` cases on a nested path like `/share/dir/a.csv` (with 
`/share/a.csv` the parent is the share and `makedirs` never runs), and a 
return-value check with distinct timestamps?



##########
providers/samba/src/airflow/providers/samba/fs/_smb_filesystem.py:
##########
@@ -0,0 +1,161 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import datetime
+from stat import S_ISDIR
+from typing import Any
+
+import smbclient
+from fsspec import AbstractFileSystem
+from fsspec.implementations.smb import (
+    SMBFileOpener,
+    SMBFileSystem,
+    _as_temp_path,
+    _as_unc_path,
+    _share_has_path,
+)
+
+from airflow.providers.samba.hooks.samba import _get_auth_protocol
+
+
+class _SMBFileOpener(SMBFileOpener):
+    """``SMBFileOpener`` that also sends the session arguments when it commits 
or discards the file."""
+
+    def __init__(self, *args: Any, session_kwargs: dict[str, Any], **kwargs: 
Any) -> None:
+        self.session_kwargs = session_kwargs
+        super().__init__(*args, **session_kwargs, **kwargs)
+
+    def commit(self) -> None:
+        smbclient.replace(self.temp, self.path, port=self.port, 
**self.session_kwargs)
+
+    def discard(self) -> None:
+        smbclient.remove(self.temp, port=self.port, **self.session_kwargs)
+
+
+class _IsolatedSMBFileSystem(SMBFileSystem):
+    """
+    ``SMBFileSystem`` that keeps its own SMB connection and sends its 
credentials with every call.
+
+    fsspec registers a session once in smbclient's process-wide pool and then 
calls smbclient without
+    credentials, so smbclient uses the first session it finds for the server. 
Two connections to the same
+    server would then both act as whichever user connected first, and once the 
server drops the
+    connection, smbclient reconnects without credentials and every call fails. 
Like ``SambaHook``, this
+    filesystem keeps a pool of its own and passes the credentials on every 
call, which opens the session
+    on first use and again after the server drops it.
+    """
+
+    def __init__(self, *args: Any, auth_protocol: str = "negotiate", **kwargs: 
Any) -> None:
+        self.auth_protocol = _get_auth_protocol({}, auth_protocol)
+        self._connection_cache: dict[str, Any] = {}
+        super().__init__(*args, **kwargs)
+
+    @property
+    def _session_kwargs(self) -> dict[str, Any]:
+        return {
+            "username": self.username,
+            "password": self.password,
+            "encrypt": self.encrypt,
+            "connection_timeout": self.timeout,
+            "connection_cache": self._connection_cache,
+            "auth_protocol": self.auth_protocol,
+        }
+
+    def _connect(self) -> None:
+        """Do not register a session up front; each call opens it in this 
filesystem's own pool."""
+
+    def ls(self, path, detail=True, **kwargs):
+        return super().ls(path, detail=detail, **{**kwargs, 
**self._session_kwargs})
+
+    def info(self, path, **kwargs):
+        return super().info(path, **{**kwargs, **self._session_kwargs})
+
+    def created(self, path):
+        stats = smbclient.stat(_as_unc_path(self.host, path), port=self._port, 
**self._session_kwargs)
+        return datetime.datetime.fromtimestamp(stats.st_ctime, tz=datetime.UTC)
+
+    def modified(self, path):
+        stats = smbclient.stat(_as_unc_path(self.host, path), port=self._port, 
**self._session_kwargs)
+        return datetime.datetime.fromtimestamp(stats.st_mtime, tz=datetime.UTC)
+
+    def mkdir(self, path, create_parents=True, **kwargs):
+        return super().mkdir(path, create_parents=create_parents, **{**kwargs, 
**self._session_kwargs})
+
+    def makedirs(self, path, exist_ok=False):
+        if _share_has_path(path):
+            smbclient.makedirs(
+                _as_unc_path(self.host, path), exist_ok=exist_ok, 
port=self._port, **self._session_kwargs
+            )
+
+    def rmdir(self, path):
+        if _share_has_path(path):
+            smbclient.rmdir(_as_unc_path(self.host, path), port=self._port, 
**self._session_kwargs)
+
+    def _rm(self, path):
+        if _share_has_path(path):
+            wpath = _as_unc_path(self.host, path)
+            stats = smbclient.stat(wpath, port=self._port, 
**self._session_kwargs)
+            if S_ISDIR(stats.st_mode):
+                smbclient.rmdir(wpath, port=self._port, **self._session_kwargs)
+            else:
+                smbclient.remove(wpath, port=self._port, 
**self._session_kwargs)
+
+    def _open(self, path, mode="rb", block_size=-1, autocommit=True, 
cache_options=None, **kwargs):
+        if "w" in mode and autocommit is False:
+            if self.auto_mkdir:
+                self.makedirs(self._parent(path), exist_ok=True)
+            kwargs.pop("share_access", None)
+            return _SMBFileOpener(
+                _as_unc_path(self.host, path),
+                _as_temp_path(self.host, path, self.temppath),
+                mode,
+                port=self._port,
+                block_size=block_size if block_size is not None and block_size 
>= 0 else -1,
+                session_kwargs=self._session_kwargs,
+                **kwargs,
+            )
+        return super()._open(
+            path,
+            mode=mode,
+            block_size=block_size,
+            autocommit=autocommit,
+            cache_options=cache_options,
+            **{**kwargs, **self._session_kwargs},
+        )
+
+    # fsspec's SMB ``copy`` passes ``recursive`` on to smbclient, which 
rejects it, so copies go through
+    # the generic ``copy`` and a server-side ``cp_file`` instead.
+    copy = AbstractFileSystem.copy
+
+    def cp_file(self, path1, path2, **kwargs):
+        if self.isdir(path1):
+            self.makedirs(path2, exist_ok=True)
+            return
+        if self.auto_mkdir:
+            self.makedirs(self._parent(path2), exist_ok=True)
+        smbclient.copyfile(
+            _as_unc_path(self.host, path1),
+            _as_unc_path(self.host, path2),
+            port=self._port,
+            **self._session_kwargs,
+        )
+
+    def mv(self, path1, path2, recursive=None, maxdepth=None, **kwargs):

Review Comment:
   `ObjectStoragePath.replace()` says it overwrites, but on SMB it ends up 
here, and `smbclient.rename` refuses an existing target 
(`replace_if_exists=False`), where local, S3 and GCS overwrite. So 
write-to-temp-then-replace fails the second time it runs. Should this call 
`smbclient.replace` instead, or should `smb.rst` call it out?



##########
providers/samba/tests/unit/samba/fs/test__smb_filesystem.py:
##########
@@ -0,0 +1,144 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import stat
+from unittest import mock
+
+import pytest
+import smbclient
+from smbclient._os import SMBStatResult
+
+from airflow.providers.samba.fs._smb_filesystem import _IsolatedSMBFileSystem, 
_SMBFileOpener
+
+SMBCLIENT_FUNCTIONS = (
+    "copyfile",
+    "listdir",
+    "makedirs",
+    "open_file",
+    "remove",
+    "rename",
+    "replace",
+    "rmdir",
+    "stat",
+)
+
+
+def make_stat(mode: int) -> SMBStatResult:
+    return SMBStatResult._make([0] * 
len(SMBStatResult._fields))._replace(st_mode=mode)
+
+
[email protected]
+def mock_smbclient():
+    """Replace the smbclient calls that fsspec and the filesystem make, with a 
regular file for ``stat``."""
+    with mock.patch.multiple(
+        smbclient, autospec=True, **dict.fromkeys(SMBCLIENT_FUNCTIONS, 
mock.DEFAULT)
+    ) as m:
+        m["stat"].return_value = make_stat(stat.S_IFREG)
+        yield m
+
+
+def make_fs() -> _IsolatedSMBFileSystem:
+    return _IsolatedSMBFileSystem(
+        host="testhost",
+        username="testuser",
+        password="testpass",
+        encrypt=True,
+        timeout=30,
+        skip_instance_cache=True,
+    )
+
+
+def assert_sends_session(call: mock._Call, fs: _IsolatedSMBFileSystem) -> None:
+    assert call.kwargs["username"] == "testuser"
+    assert call.kwargs["password"] == "testpass"
+    assert call.kwargs["port"] == 445
+    assert call.kwargs["encrypt"] is True
+    assert call.kwargs["connection_timeout"] == 30
+    assert call.kwargs["auth_protocol"] == "negotiate"
+    assert call.kwargs["connection_cache"] is fs._connection_cache
+
+
+class TestAirflowSMBFileSystem:

Review Comment:
   Nit: this tests `_IsolatedSMBFileSystem`, so `TestIsolatedSMBFileSystem`?



##########
providers/samba/src/airflow/providers/samba/fs/_smb_filesystem.py:
##########
@@ -0,0 +1,161 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import datetime
+from stat import S_ISDIR
+from typing import Any
+
+import smbclient
+from fsspec import AbstractFileSystem
+from fsspec.implementations.smb import (

Review Comment:
   fsspec/filesystem_spec#2006 already tracks the shared-session problem. Could 
the class docstring link it, and is the `copy` passing `recursive` one reported 
upstream? This overrides nearly every `SMBFileSystem` method and imports three 
private helpers with no fsspec upper bound, so a rename upstream breaks every 
`smb://` path, and the links say when the subclass can go.



##########
providers/samba/src/airflow/providers/samba/fs/_smb_filesystem.py:
##########
@@ -0,0 +1,161 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import datetime
+from stat import S_ISDIR
+from typing import Any
+
+import smbclient
+from fsspec import AbstractFileSystem
+from fsspec.implementations.smb import (
+    SMBFileOpener,
+    SMBFileSystem,
+    _as_temp_path,
+    _as_unc_path,
+    _share_has_path,
+)
+
+from airflow.providers.samba.hooks.samba import _get_auth_protocol
+
+
+class _SMBFileOpener(SMBFileOpener):
+    """``SMBFileOpener`` that also sends the session arguments when it commits 
or discards the file."""
+
+    def __init__(self, *args: Any, session_kwargs: dict[str, Any], **kwargs: 
Any) -> None:
+        self.session_kwargs = session_kwargs
+        super().__init__(*args, **session_kwargs, **kwargs)
+
+    def commit(self) -> None:
+        smbclient.replace(self.temp, self.path, port=self.port, 
**self.session_kwargs)
+
+    def discard(self) -> None:
+        smbclient.remove(self.temp, port=self.port, **self.session_kwargs)
+
+
+class _IsolatedSMBFileSystem(SMBFileSystem):
+    """
+    ``SMBFileSystem`` that keeps its own SMB connection and sends its 
credentials with every call.
+
+    fsspec registers a session once in smbclient's process-wide pool and then 
calls smbclient without
+    credentials, so smbclient uses the first session it finds for the server. 
Two connections to the same
+    server would then both act as whichever user connected first, and once the 
server drops the
+    connection, smbclient reconnects without credentials and every call fails. 
Like ``SambaHook``, this
+    filesystem keeps a pool of its own and passes the credentials on every 
call, which opens the session
+    on first use and again after the server drops it.
+    """
+
+    def __init__(self, *args: Any, auth_protocol: str = "negotiate", **kwargs: 
Any) -> None:
+        self.auth_protocol = _get_auth_protocol({}, auth_protocol)
+        self._connection_cache: dict[str, Any] = {}
+        super().__init__(*args, **kwargs)
+
+    @property
+    def _session_kwargs(self) -> dict[str, Any]:
+        return {
+            "username": self.username,
+            "password": self.password,
+            "encrypt": self.encrypt,
+            "connection_timeout": self.timeout,
+            "connection_cache": self._connection_cache,
+            "auth_protocol": self.auth_protocol,
+        }
+
+    def _connect(self) -> None:
+        """Do not register a session up front; each call opens it in this 
filesystem's own pool."""

Review Comment:
   With `_connect` a no-op, bad credentials no longer fail when the filesystem 
is built, and fsspec's `exists()` turns every exception into `False`. So 
`exists()` on a connection with a wrong password returns `False`, and a sensor 
polling it waits for its timeout instead of failing. Should `exists` here only 
treat not-found as `False`?



##########
providers/samba/tests/unit/samba/fs/test_smb.py:
##########
@@ -0,0 +1,109 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from unittest import mock
+
+import pytest
+
+from airflow.providers.samba.fs.smb import get_fs, schemes
+
+TEST_CONN_ID = "smb_fs_test_conn"
+FS_CLASS = "airflow.providers.samba.fs._smb_filesystem._IsolatedSMBFileSystem"
+
+
[email protected]
+def smb_connection(monkeypatch):
+    def _set(uri: str) -> None:
+        monkeypatch.setenv(f"AIRFLOW_CONN_{TEST_CONN_ID}".upper(), uri)
+
+    return _set
+
+
+class TestSmbFilesystem:
+    def test_schemes(self):
+        assert schemes == ["smb"]

Review Comment:
   This restates the constant. Would a test that 
`ObjectStoragePath("smb://conn@/share/a.csv")` resolves to this filesystem 
cover the registration instead?



##########
providers/samba/pyproject.toml:
##########
@@ -60,7 +60,8 @@ requires-python = ">=3.11"
 dependencies = [
     "apache-airflow>=2.11.0",
     "apache-airflow-providers-common-compat>=1.10.1",

Review Comment:
   Not from this PR, but `hooks/samba.py` imports 
`AirflowOptionalProviderFeatureException` from `common.compat.sdk`, which first 
shipped in common-compat 1.12.0, and the new `fs` modules import from the hook. 
With 1.10.1 or 1.11.0 installed, `get_fs` fails with an `ImportError`. Should 
this go to `>=1.12.0` here? It needs the `allow provider dependency bump` 
label, so a separate PR works too since the hook already has this problem.



##########
providers/samba/src/airflow/providers/samba/fs/smb.py:
##########
@@ -0,0 +1,54 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from typing import TYPE_CHECKING, Any
+
+from airflow.providers.common.compat.sdk import BaseHook
+
+if TYPE_CHECKING:
+    from fsspec import AbstractFileSystem
+
+schemes = ["smb"]
+
+
+def get_fs(conn_id: str | None, storage_options: dict[str, Any] | None = None) 
-> AbstractFileSystem:
+    # Imported here so that discovering filesystems does not load smbclient in 
every process.
+    from airflow.providers.samba.fs._smb_filesystem import 
_IsolatedSMBFileSystem
+    from airflow.providers.samba.hooks.samba import _get_auth_protocol
+
+    if conn_id is None:

Review Comment:
   With no connection (`smb://host/share/a.csv`), `_inject_authenticated_fs` 
skips the injection, so `exists()` and `iterdir()` run on fsspec's own 
`SMBFileSystem` and its shared session pool, and only `open()` and `stat()` hit 
this error. Worth a line in `smb.rst` saying a connection id is required?



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

Reply via email to