Skip to content

Added deprecation warning for anonymous access#530

Merged
kyleknap merged 6 commits intofsspec:mainfrom
anjaliratnam-msft:default-azure-creds
Feb 3, 2026
Merged

Added deprecation warning for anonymous access#530
kyleknap merged 6 commits intofsspec:mainfrom
anjaliratnam-msft:default-azure-creds

Conversation

@anjaliratnam-msft
Copy link
Copy Markdown
Collaborator

@anjaliratnam-msft anjaliratnam-msft commented Jan 23, 2026

Added a deprecation warning for changing the anonymous access default to False. The message will only show up if users do not provide a credential or explicitly set anon.

To continue using anonymous access, users should pass in anon=True. e.g.:
AzureBlobFileSystem(account_name=<your-account-name>,...,anon=True,)

Copy link
Copy Markdown
Collaborator

@nateprewitt nateprewitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor comments and a question. Please let me know if I'm missing anything.

Comment thread CHANGELOG.md Outdated
Comment on lines +17 to +18
* Changed default value of `anon` to `False`. Explicitly pass in `True` to use anonymous
credentials.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we're changing the default just yet. We may want to rephrase this to be forward looking. Something like:

**Breaking:** Warning added for default anonymous use. Default adlfs use will require credentials starting in a future release. Anyone requiring anonymous access should explicitly set `anon=True` when creating their AzureFileSystem.

I'd also suggest adding a small example snippet in this PR description for anyone looking. That will make it clear what changes they need to make.

Comment thread adlfs/spec.py Outdated
"0",
"f",
]
if self.anon:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little subtle but I think we may incorrectly flag usage. If I set AZURE_STORAGE_ANON to "true", I would expect that to continue working. We shouldn't be breaking that with the default change.

The case we're concerned about here is closer to os.getenv("AZURE_STORAGE_ANON", None) is None. We want the case where both the env var isn't set and the variable isn't declared explicitly.

Comment thread adlfs/spec.py
Comment on lines +321 to +325
if (
self.sas_token is None
and self.account_key is None
and credential is None
):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can go take a look if you don't know off hand. If anon is True but we have credentials available, are they used or do we ignore them?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Building on what @nateprewitt said, I think it would be worth adding tests for the different credential permutations on when and when we don't warn about switching the anon default. I think if we are able to build up a good set of cases, we will have a much better understanding on when the default is reached and if there are any cases we did not account for. Furthermore, when we go to switch the default, we should hopefully be able to just update the assertion, reusing all of the cases that we've enumerated, and make that change easier/safer.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The credentials are checked first so it will use them before anon.

Copy link
Copy Markdown
Collaborator

@nateprewitt nateprewitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor notes on the tests but otherwise looks good! I noticed though that the test suite now has a lot of these warnings being raised:

adlfs/tests/test_spec.py: 67 warnings
  /opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/fsspec/spec.py:84: DeprecationWarning: The default for anonymous access will be changing to False. To continue using anonymous credentials, please set anon=True. 
    obj = super().__call__(*args, **kwargs, **strip_tokenize_options)

I think that's probably fine since this is a short time window, but I'm wondering if we should test changing the default and see what (if anything) breaks in the test suite with the cutover. That will help inform how much work needs to be done in advance.

Comment thread adlfs/spec.py Outdated
"0",
"f",
]
if self.anon and os.getenv("AZURE_STORAGE_ANON") is None:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can ignore the value of self.anon for this check, and just check the value of the environment variable. If it's not set (i.e. None), we know the end user hasn't specified a preference through the anon parameter or environment. That means we're using defaults which is the case where we want the warning.

Suggested change
if self.anon and os.getenv("AZURE_STORAGE_ANON") is None:
if os.getenv("AZURE_STORAGE_ANON") is None:

Comment thread adlfs/tests/test_spec.py Outdated
Comment on lines +2388 to +2390
("true", None, None, None, None, False),
("false", None, None, None, None, False),
("true", None, "credential", None, None, False),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anon is defined as an optional bool so we should try to keep tests reflecting the public API.

Suggested change
("true", None, None, None, None, False),
("false", None, None, None, None, False),
("true", None, "credential", None, None, False),
(True, None, None, None, None, False),
(False, None, None, None, None, False),
(False, None, "credential", None, None, False),

Comment thread adlfs/tests/test_spec.py Outdated
):
env_var = {} if env_value is None else {"AZURE_STORAGE_ANON": env_value}
with mock.patch.dict(os.environ, env_var):
if warning:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more high-level testing advice for Python, so you can do with it what you want. Generally, it's good to avoid conditionals inside tests. Once you introduce branching logic, it's not uncommon to silently break things while the tests continue to report success.

pytest.mark.parameterize is great for simplifying code, but there's also cases where you may want to make distinctions between what you're testing (positive cases, negative cases, env vs not, etc).

You might consider two tests here. We can also get a little clever with the testing inputs if you want, but not required at all.

test_anon_warning (positive test for case 1, ensure the warning is raised where we expect)
test_no_anon_warning (negative tests for cases 2-10)

@anjaliratnam-msft
Copy link
Copy Markdown
Collaborator Author

I think that's probably fine since this is a short time window, but I'm wondering if we should test changing the default and see what (if anything) breaks in the test suite with the cutover. That will help inform how much work needs to be done in advance.

It looks like it's because the connection string is set for most tests. I'm assuming we don't want the warning when it's set, so I included it in the check as well.

@kyleknap
Copy link
Copy Markdown
Collaborator

Yeah we definitely do not want to warn if connection string is provided; connection strings count as one of the ways to provide credentials and avoid defaulting to anonymous credentials.

Copy link
Copy Markdown
Collaborator

@nateprewitt nateprewitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! I think one test is still raising the warning, but it's testing anonymous access so we should be alright leaving it to be updated with the default change.

Copy link
Copy Markdown
Collaborator

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I just had some smaller comments.

Comment thread adlfs/spec.py
Comment thread adlfs/spec.py Outdated
and self.connection_string is None
):
warnings.warn(
"The default for anonymous access will be changing to False. To continue "
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the first sentence, maybe let's change it to:

AzureBlobFileSystem will no longer be defaulting to anonymous authentication in an upcoming release.

Mainly it took me several passes to understand what changing anonymous to false at a high level meant. I imagine this might be a little hard to follow for others that are not necessarily following this change.

Comment thread adlfs/tests/test_spec.py Outdated


@pytest.mark.parametrize(
"anon,env_value,credential,sas_token,account_key",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be interesting if we could trim the parameterization down to just generalized env_vars and storage_options (which would be just the filesystem keyword arguments). Mainly it's a little difficult to follow the order of parameter right now and if we want to add any more configuration options (e.g., connection string, client id), it will bloat the parameters even more.

Comment thread adlfs/tests/test_spec.py
Copy link
Copy Markdown
Collaborator

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just had a couple more suggestions and I think we should be good here.

Comment thread adlfs/tests/test_spec.py Outdated
Comment on lines +2408 to +2412
mocker.patch.object(
AzureBlobFileSystem,
"_get_credential_from_service_principal",
return_value=(None, None),
)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think to avoid the patch, we should be also be able to set a fake secret and tenant id to get the pass validation. I was setting the configuration value like this (there should be env vars that we can use too) and I was not running into any errors:

    AzureBlobFileSystem(
        account_name="<account-name>",
        client_id="<client-id>",
        client_secret="<client-secret>",
        tenant_id="00000000-0000-0000-0000-000000000000",
    )

I'm thinking we should just update the test cases to include fake values like that instead of adding another patch.

Comment thread adlfs/tests/test_spec.py Outdated
(None, {"account_key": "account_key"}),
({"AZURE_STORAGE_ANON": "true"}, {}),
({"AZURE_STORAGE_ANON": "false"}, {}),
({"AZURE_STORAGE_ANON": "true", "credential": "credential"}, {}),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the credential for this case supposed to be in the storage_options and not the env_vars?

Copy link
Copy Markdown
Collaborator

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for digging into all of the different credential options here. 🚢

@kyleknap kyleknap merged commit 2acd716 into fsspec:main Feb 3, 2026
8 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants