From 7ba06d84d13f24062563c8bc792068c3de2d661c Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Sat, 24 Oct 2026 17:26:03 -0700 Subject: [PATCH] fix(fsspec): parse adls.anon as a boolean adls.anon was passed to adlfs as a string, and adlfs only uses default credentials when anon is False, so "false" silently disabled them. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- pyiceberg/io/fsspec.py | 2 +- tests/io/test_fsspec.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pyiceberg/io/fsspec.py b/pyiceberg/io/fsspec.py index 98275f25a7..f76f894bf3 100644 --- a/pyiceberg/io/fsspec.py +++ b/pyiceberg/io/fsspec.py @@ -308,7 +308,7 @@ async def get_token(self, *scopes: str, **kwargs: Any) -> AccessToken: client_id=properties.get(ADLS_CLIENT_ID), client_secret=properties.get(ADLS_CLIENT_SECRET), account_host=properties.get(ADLS_ACCOUNT_HOST), - anon=properties.get(ADLS_ANON), + anon=property_as_bool(properties, ADLS_ANON, False) if properties.get(ADLS_ANON) not in (None, "") else None, ) diff --git a/tests/io/test_fsspec.py b/tests/io/test_fsspec.py index 7b9d871550..9f868d0794 100644 --- a/tests/io/test_fsspec.py +++ b/tests/io/test_fsspec.py @@ -756,6 +756,22 @@ def test_adls_account_name_not_overridden_when_in_properties() -> None: ) +def test_adls_anon_parsed_as_bool() -> None: + cases: list[tuple[Properties, bool | None]] = [ + ({"adls.anon": "false"}, False), + ({"adls.anon": "true"}, True), + ({"adls.anon": False}, False), + ({"adls.anon": True}, True), + ({}, None), + ] + for properties, expected in cases: + with mock.patch("adlfs.AzureBlobFileSystem") as mock_adlfs: + adls_fileio = FsspecFileIO(properties=properties) + adls_fileio.new_input(location="abfss://data@accountone.dfs.core.windows.net/wh/t/a.parquet") + + assert mock_adlfs.call_args.kwargs["anon"] is expected + + @pytest.mark.gcs def test_fsspec_new_input_file_gcs(fsspec_fileio_gcs: FsspecFileIO) -> None: """Test creating a new input file from a fsspec file-io"""