Propagate storage_options to all backends resolved by GenericFileSystem (#1856) - #2083
Merged
martindurant merged 1 commit intoJul 23, 2026
Merged
Conversation
| _token = "s3kr3t" | ||
|
|
||
| def __init__(self, *args, token=None, **kwargs): | ||
| if token != self._token: |
Member
There was a problem hiding this comment.
Same as if token is not None? Then you would not need the class attribute _token.
Comment on lines
+167
to
+181
| @pytest.mark.parametrize( | ||
| "op", | ||
| [ | ||
| lambda fs: fs.info("optsrequired:///afile"), | ||
| lambda fs: fs.ls("optsrequired:///adir"), | ||
| lambda fs: fs.cat_file("optsrequired:///afile"), | ||
| lambda fs: fs.isdir("optsrequired:///adir"), | ||
| lambda fs: fs.find("optsrequired:///adir"), | ||
| ], | ||
| ) | ||
| def test_storage_options_propagated_to_backend(opts_fs, op): | ||
| # GH#1856: several GenericFileSystem methods resolved the backend without | ||
| # passing storage_options, so credentialed filesystems were constructed | ||
| # bare. isdir() is included because it reaches the backend via _info(). | ||
| op(opts_fs) |
Member
There was a problem hiding this comment.
This is unnecessarily verbose: please just move those operations inline rather than parametrising, and remove the comment here and in the other tests.
balramthewarrior
force-pushed
the
fix-1856-storage-options
branch
from
July 23, 2026 06:08
e3400d7 to
28c9e68
Compare
Contributor
Author
|
Thanks for the review. Done both:
Pushed. Confirmed the two tests still fail against master without the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1856.
Root cause
GenericFileSystemstoresstorage_optionsasself.st_optsand resolves a backend per call via_resolve_fs. Withdefault_method="options",_resolve_fslooks upstorage_options[protocol]to construct the backend — so omitting the argument silently builds an unconfigured filesystem.Of the 14
_resolve_fscall sites, only 5 passedstorage_options=self.st_opts. The other 9 dropped it:_info,_ls,_cat_file,_rm,_cp_file(both sides),_make_many_dirs, and_copy(both sides).Any credentialed backend reached through those paths was constructed bare, which is what breaks
rsyncacross filesystems with different protocols or credentials.On the reported
isdirfailureThe issue proposes adding an explicit
GenericFileSystem._isdir. I don't think that's needed, and it matches your reply on the thread:That fallback works fine. The reason
isdirfailed is that it reaches the backend through_info, which was one of the 9 sites droppingstorage_options. Fixing the propagation makesisdirwork through the existing fallback — no new method required. There's a regression test covering exactly this.Change
Pass
storage_options=self.st_optsat the 9 remaining_resolve_fscall sites. No behaviour change whenstorage_optionsis unset (_resolve_fsalready coercesNoneto{}), and no change for thedefault/generic/currentmethods, which ignore the argument.Tests
Added to
fsspec/tests/test_generic.py:_OptionsRequiredFS, aMemoryFileSystemsubclass that raises unless itstokenstorage option arrives — standing in for a filesystem needing real credentials, so dropped options fail loudly instead of silently falling back to an unauthenticated instance.test_storage_options_propagated_to_backend— parametrized overinfo,ls,cat_file,isdir,find.test_storage_options_propagated_cross_protocol— the reporter's original call shape:rsyncfrom a credentialed remote to local, configured viainst_kwargs.Against unpatched master these give 5 failed / 8 passed.
findpasses on both, since_findwas already among the 5 correct call sites, so the tests track this specific defect rather than failing broadly. Full suite: 1558 passed, 0 failed.ruff check,ruff formatandcodespellclean.