Skip to content

Read a version ID query only after a key, and not as a glob (GH-1491) - #1551

Merged
laughingman7743 merged 10 commits into
masterfrom
fix/1491-version-query-grammar
Nov 30, 2026
Merged

laughingman7743 merged 10 commits into
masterfrom
fix/1491-version-query-grammar

Conversation

@laughingman7743

@laughingman7743 laughingman7743 commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

WHAT

The version-query half (b) of #1491: decision 4 of the #1493 audit and defects 6, 7 and 9.

  • S3Path.parse() applies the rule of Keep the slashes that end a version ID in path strings (GH-1469) #1481 (get() pairs conflicting local destinations: an object with the keys below it, and a folder marker with its directory #1487 item 2): a query whose version ID is empty or has only slashes names no version and is part of the key. s3://bucket/key?versionId=/ now names the key key?versionId=/ in the methods that parse a path as given (cat_file, rm_file, touch, cp_file, tags, metadata, xattrs, chmod, sign, object_version_info, list_multipart_uploads, the cp_file destination) instead of the version / of key. The strip-first methods already read it as the key key?versionId=, and keep doing so. A version ID that ends in a slash (?versionId=v1/) or starts with one (?versionId=/v1) is still a version.
  • A version ID query is read only after a key: bucket?versionId=v1, bucket/?versionId=v1 (and bucket?versionId=/) raise ValueError: Invalid S3 path format from S3Path.parse(). They named a version of the bucket path, which the methods then handled differently (rm_file() returned without a request, mv() looked the bucket up and moved nothing, info() and ls() used the bucket, rm() raised Cannot delete the bucket., rmdir() dropped the version). bucket//?versionId=v1 stays version v1 of the key /, and S3Path.is_bucket is False for a path with a version, so rm() now deletes that version as rm_file() and mv() already did, instead of raising Cannot delete the bucket. The ls(), find() and chmod() checks for a version drop the key condition that only the bucket path with a version needed.
  • S3Path.is_glob() (used by S3PathPairing) and the expansion of rm(), copy(), mv(), cat(), get() and expand_path() do not read a path that ends in the form of a version ID query, also with an empty or slash-only ID, as a glob pattern. rm("s3://bucket/key?versionId=") also deleted keyXversionId=, and mv()/copy()/get()/cat() likewise took the decoy. This holds for the whole path, also where *, ? or [ occur before the query, as it already did for a path with a version. glob() itself still reads such a string as a pattern.
  • copy()/mv() name a destination below a string path2 by parsing path2 and adding the suffix to its key (S3PathPairing.s3_copy_pairs), as already done for listed S3Path sources; the string is kept when it names the same path. copy("s3://bucket/k", "s3://bucket/key?versionId=/") writes key?versionId=/k (it raised Cannot copy to a versioned file.: the joined string parsed as version /k of key), a version of a key ending in a query (a?versionId=v1?versionId=v2) is copied into a directory under its key's name, and a bucket path with a version as path2 raises before anything is copied or deleted.
  • expand_path() parses the paths with a version ID, so a bucket path with a version raises there too; invalidate_cache() of the listed name of a root key such as bucket/?versionId=v1 evicts that name only, not the other spellings of the query.
  • docs/filesystem.md and the S3Path docstrings state the grammar, including that the listed name of a key such as ?versionId=v1 at the bucket root raises ValueError when passed back as a path string (it named the bucket before).

Out of scope, as agreed on #1491: the entry point (a) after #1454 (s3::, doubled prefixes, S3Path passed inward), and the two cases of the 2026-11-29 comment (cp_file trailing-slash lookup, touch("s3://bucket//")), which go with (a) and #1511. Trailing slashes keep their current targets (#1511): e.g. touch("s3://bucket/key?versionId=/") writes the key key?versionId=/, while pipe_file() of the same string writes key?versionId=, as for any dir/.

Behavior change, with a release note on master and 4.x: bucket paths with a version query raise ValueError; ?versionId= with an empty or slash-only ID is a key everywhere and is not expanded as a glob. It goes to 4.x through the backport session after it merges.

WHY

Part (b) of #1491 (item 1 of the split); the audit is #1493 (decision 4; defects 6, 7, 9). It lands before (a), because passing S3Path inward would otherwise drop the #1481 rule for the strip-first methods.

TEST

Tested commit: 74353d2, rebased on master ce72fcc (after #1538, #1541, #1548, #1532).

  • just lint, just docs lint: pass.
  • just test offline (the offline target of Add an offline test target that no AWS account authorizes (GH-1495) #1532): 4,252 passed, none failed. No live AWS run.
  • New and changed tests run against the merge-base code: every new-behavior case fails there (parser, is_glob, cache invalidation, rejected bucket paths, rm/mv of the empty and slash-only queries, rm of bucket//?versionId=v1); the boundary cases (?versionId=v1/, ?versionId=/v1, mv of bucket//?versionId=v1) pass on both.
  • Tests changed because they pinned the old grammar, including, after the rebase, the cp_file copies another object than it looks up, and a recursive copy of a bucket raises #1510 case of test_s3_copy_pairs_bucket that paired the source bucket?versionId=v1 (now test_s3_copy_pairs_bucket_with_version, which expects ValueError): the bucket?versionId=v1 / bucket/?versionId=v1 cases of test_s3_path.py::test_parse, test_rm_bucket, test_ls_empty_bucket, the aio test_put_checks_destinations_first[no-key] (now bucket and bucket/), and the ?versionId=/ case of test_invalidate_cache_version_drops_object_path, which now has its own test: that spelling no longer invalidates the lookup of a/c.txt, which it named only by reading / as a version.

Differential check

Offline, moto mock_aws() per case; same seeded versioned bucket for every case (k, key@v1/v2, key?versionId=, key?versionId=/, decoy keyXversionId=, dir/, dir/a, dir/b, x/y, /@s1, one pending upload of key), fresh filesystem and empty request log per case. Recorded: result, exception, request multiset (_make_api_call params), bucket versions/delete markers/uploads after the call, local files.

  • Matrix: 26 spellings × 48 operations × sync / aio sync wrappers / aio coroutines = 3,666 cases. Spellings: key, key?versionId=v1, key?versionId=v1/, key?versionId=, key?versionId=/, key?versionId=//, key?version_id=/, key?versionid=, bucket/key?versionId=/, key?, key?versionId=?, keyXversionId=, key*, dir/, dir/a?versionId=, bucket, bucket/, bucket//, bucket?versionId=v1 (with and without s3://), bucket/?versionId=v1, bucket//?versionId=s1, bucket?versionId=, bucket?versionId=/, bucket/?versionId=/, bucket/?versionId=. Operations: info, exists, isfile, isdir, ls, find (±withdirs), walk, du, glob, expand_path (±recursive), cat (±recursive), cat_file, open+read, size, get_file, get (±recursive), rm_file, rm (±recursive), rmdir, mkdir, touch (±truncate), pipe_file, put_file, cp_file/copy/copy recursive/mv from the path, cp_file/copy/mv to the path, checksum, created, modified, sign, metadata, getxattr, setxattr, get_tags, put_tags, chmod, object_version_info, list_multipart_uploads.
  • Merge base run twice: identical except the request log of recursive get() of the bucket root (bucket, bucket/, bucket//), where whether HeadObject dir is sent depends on the thread schedule; only that field of those cells is excluded, their results, state and local files are compared.
  • Branch vs merge base ce72fcc (both merge-base runs, which were identical): 1,083 differing cases, all in the expected rows, none missing: the slash-only spellings in the parse-as-given and expanding methods; the empty-ID spellings (key?versionId=, key?versionid=, dir/a?versionId=, bucket/?versionId=) in the expanding methods only; every method for the bucket paths with a version; bucket/?versionId=/ (now the key ?versionId=/); and s3://bucket?versionId= in the expanding methods (Cannot traverse all files in S3 → Invalid S3 path format). copy/mv from k into the four slash-only spellings (write key?versionId=/k), cp_file of key?version_id=/ (since cp_file copies another object than it looks up, and a recursive copy of a bucket raises #1510 it looks up the parsed source: the key key?version_id=/ instead of version / of key), and rm/rm -r of bucket//?versionId=s1 (deletes version s1 of / instead of Cannot delete the bucket.). key?versionId=v1/ and all other spellings and methods are unchanged. The cleanup commit c901e64 changes no case against 9cc87a4. A second schedule-dependent request log is excluded: cat("s3://bucket/dir/", recursive=True) fails fast on the GetObject of dir (NoSuchKey), so how many of the parallel sibling GetObjects are sent varies (seen in 3 of ~34 branch runs and 0 of ~34 merge-base runs of that cell; the code path has no version query); its exception and state are compared.
  • Checked against plain-key neighbors: on the branch, rm/mv/copy -r of key?versionId=/ act exactly as those of kk/ with keys kk, kk/, kk/a, and a missing key?versionId=-shaped key behaves as s3://bucket/missing (rm silent, cat FileNotFoundError, expand_path returns the name).

Recorded for (a) on #1491 (after consulting Codex and Claude Fable 5.2): isfile() returning False for invalid paths, validation of a keyless version in the S3Path model, reopening a file opened with an S3Path (pre-existing AttributeError), validation of literal names in expand_path(), and retiring the any-string helpers.

🤖 Generated with Claude Code

"""
match = cls.PATTERN.search(path)
if not match:
# A version ID query is read only after a key.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Self-review round one (implementation behavior) — FINDINGS, repaired

Base fc8c0cfc05351eb2646339d31a7113ea3d16c15a, initial head 302aba01c45fbb468592db6fab01d4ceb2c8a84e, repaired head c901e64b5458bc837d45002859fb2b3ca89463fa.
Covered: S3Path grammar (PATTERN, VERSION_QUERY, parse, is_glob, has_version_id/split_version_id/split_trailing_separators/version_separators, is_bucket), their callers in s3.py (_expand_unversioned, _ls, _find_paths, chmod, _parent), s3_cache.py invalidation, S3PathPairing (looks_up_destination, copy_pairs, delete_paths), aio paths through the shared helpers, docs and tests. Included /code-review high and /simplify passes.

Differential check rerun on the repaired head: 3,666 cases, 1,047 expected differences, 0 unexpected, 0 missing, against two merge-base runs.

Repaired:

  1. s3_path_pairing.py delete_paths: rm("s3://bucket//?versionId=v1") raised Cannot delete the bucket. while rm_file()/mv() deleted the version, contrary to decision 4. S3Path.is_bucket (s3_path.py:261) is now False for a path with a version; rm deletes it as given (test test_rm_version_query_shape[s3://bucket//?versionId=v1-...], fails on base).
  2. PATTERN repeated the query grammar in a lookahead; it keeps its old form and parse() rejects a version without a key (this line). Parser results unchanged (probe table and matrix).
  3. Docs: a path ending in an empty/slash-only query is not a glob for the whole path (also */[ before the query); the listed name of a root key ?versionId=v1 raises when passed back.
  4. Tests: mv test also asserts the deletion (via s3_copy_targets/s3_request_targets); duplicate test_ls_empty_bucket[s3://bucket/] dropped; rejection test reduced to one spelling × one method per parsing style; dead return_value removed; dead key and conditions at s3.py _ls/_find_paths/chmod removed.
  5. Test comment claimed mv() of a bucket path with a version sent no request; on base it sent HeadBucket and moved nothing. Corrected.

Not changed, with reasons:

  • has_version_id/split_version_id/partition_by_version still answer bucket?versionId=v1 as versioned: they accept any string by contract (fsspec-built names), and every method that consumes the path then parses and raises; invalidate_cache() of that string over-evicts the bucket listing only.
  • S3Path(bucket, None, "v1") / S3Path(b, "k", "/") remain constructible and do not round-trip through str(): the model never promised a round trip (keys ending in a query already do not), and constructor validation would be a model contract change outside (b).
  • delete_paths scans each path twice (parse + partition_by_version): pre-existing, microseconds.
  • Pre-existing, unchanged by this PR, noted in the PR body for (a): expand_path() without recursive returns bucket?versionId=v1 unparsed; isfile() returns False for it; copy/mv into the directory key?versionId=/ raise Cannot copy to a versioned file.

Comment thread docs/filesystem.md
not a glob pattern for `rm()`, `copy()`, `mv()`, `cat()`, `get()` and `expand_path()`,
also where `*`, `?` or `[` occur before the query: `rm("s3://YOUR_S3_BUCKET/key?versionId=")`
deletes only the key `key?versionId=`.
A bucket path with a version, such as `s3://YOUR_S3_BUCKET?versionId=v1` or

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Self-review round two (claims, callers, operations, evidence) — FINDINGS, corrected

Base fc8c0cfc05351eb2646339d31a7113ea3d16c15a, head c901e64b5458bc837d45002859fb2b3ca89463fa.
Claims checked against the merge-base matrix data and probes:

  • PR body, test comments and commit messages on old behavior: rm_file() returned without a request, mv() sent HeadBucket and moved nothing (corrected from "returned without a request"), info()/ls() used the bucket, rm() raised Cannot delete the bucket., rmdir() dropped the version (PermissionError of bucket deletion); rm("…/key?versionId=") deleted keyXversionId= too; rm("…/key?versionId=/") sent DeleteObjects key@/; mv of both moved both keys into dst/; the cache invalidation of a/c.txt?versionId=/ evicted the a/c.txt lookup. All confirmed.
  • Docs (this section): bucket//?versionId=v1 is version v1 of / — now true for every method including rm() (round-one repair 1). The listed-name sentence (line 740) is new and matches info(ls(...)[0]) for a root key ?versionId=v1.
  • Existing callers: strip-first methods unchanged for the slash-only spellings; glob() unchanged; ?versionId=v1/ and /v1 versions unchanged; no request is added (expansion of key?versionId= no longer lists).
  • Release-note claim corrected to "behavior change, release note on master and 4.x" since the change also goes to 4.x.
  • Evidence: offline only (--noconftest, failure/error set identical to base); no live AWS run; sync tests only, aio covered by the differential matrix (sync wrappers and coroutines, no parity regression).

for p1, p2 in pairs
]

def destination(p1: str | S3Path, p2: str) -> str | S3Path:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Independent review (relayed) — Codex CLI 0.172.0, codex exec -s read-only, static review (no tests run), detached snapshot of c901e64b5458bc837d45002859fb2b3ca89463fa, base fc8c0cfc05351eb2646339d31a7113ea3d16c15a, prompt without PR number/description/author conclusions; given the diff, conventions, docs/testing.md and the differential harness. Result: FINDINGS (6). Verified each on the merge base and the branch (offline moto probes):

  1. High, confirmed regression of this PR, repaired in 93b1f804 (this function): mv(["s3://bucket/key?versionId="], "s3://bucket/?versionId=v1") moved the key to ?versionId=v1/key?versionId= and deleted the source; on the merge base it raised Cannot copy to a versioned file. Same root as the copy into key?versionId=/: destinations named below a string path2 were joined strings. Now path2 is parsed (bucket path with a version raises) and the suffix is added to its key; the string is kept when it names the same path. Tests: test_s3_copy_pairs_bucket_destination_with_version, test_mv_into_bucket_path_with_version_keeps_source, test_copy_into_directory_named_with_a_query, two test_s3_copy_pairs cases (all fail on the merge base).
  2. Medium expand_path() without recursive returned bucket/?versionId=v1: repaired, _expand_paths parses the paths with a version ID (s3.py:2005); other literal names stay unvalidated. Test: test_bucket_path_with_version_is_rejected[expand_path].
  3. Low invalidate_cache("bucket/?versionId=v1") evicted the other spellings (?versionID=v1) as aliases of a bucket version: repaired in s3_cache.py (a version only when the base has a key). Test: test_invalidate_cache_root_key_keeps_other_spellings; the existing literal-eviction case still passes.
  4. Low S3Path("bucket", version_id="v1").is_bucket changed to False: repaired, is_bucket is True without a key and False only for a slash-only key with a version (s3_path.py:261).
  5. Low docs: setxattr sentence now says "a path with a version ID" (key?versionId= writes the literal key, as on the merge base). The reopen of a file opened with S3Path("bucket", "?versionId=v1") raises AttributeError: 'S3Path' object has no attribute 'startswith' on the merge base too: pre-existing, recorded for (a) on Parse caller-supplied S3 paths with one parser in every filesystem method #1491 (every method takes an S3Path).
  6. Low tests: the rm case of the rejection test only differed by message on the merge base → replaced by expand_path; the ?versionId=/ cache test again asserts that the v2 lookup is kept and evicts the literal a/c.txt?versionId=/ lookup.

Differential check after the repair: 1,080 expected differences against both merge-base runs, 0 unexpected, 0 missing; new expected rows: copy_to/mv_to of the four slash-only spellings (write key?versionId=/k). One more pre-existing schedule-dependent request log excluded: cat("s3://bucket/dir/", recursive=True) fails fast on GetObject dir, so how many sibling GetObjects are sent varies (seen once in 30 stress runs; exception and state still compared).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Independent follow-up (relayed): Codex, codex exec -s read-only, static review of c901e64b..93b1f804 on a detached snapshot. Result: FINDINGS (7). All repaired in 771d75ac except finding 5:

  1. s3_copy_pairs() parsed path2 when a contents copy named path2 itself without its slash ("s3://src/k/" → "s3://dst/out?versionId=v1/"). Fixed: path2 is parsed only for a destination named below it or for an S3Path source. Test: test_s3_copy_pairs_contents_into_versioned_destination.
  2. No test covered a joined string that does not parse. Added s3://bucket/k → s3://bucket/?versionId=/, which gives S3Path("bucket", "?versionId=/k").
  3. No test covered the is_bucket repair. Added S3Path("bucket", None, "v1") → True.
  4. The rm case of the rejection test is back. On the merge base it raised Cannot delete the bucket. before any request; the case guards against rm() skipping the path silently.
  5. Rejected. The finding was that the tests match undocumented message text. The repository's ruff config (PT011) requires match= on pytest.raises(ValueError), and the existing parser tests (test_parse_invalid) already match Invalid S3 path format.
  6. Docs fixed:
    • isfile() returns False, and cat_ranges() follows on_error.
    • fsspec.open_files() given a list in read mode expands each path containing *, ? or [ as a glob unless expand=False (fsspec/core.py:625). This also happens on the merge base.
    • The expand_path()/_expand_path() docstrings name the new ValueError.
  7. Docs fixed: s3_copy_pairs() returns S3Path destinations only when path2 is a string.

Differential check at 771d75ac: 1,080 expected differences against both merge-base runs, 0 unexpected, 0 missing; no case changed against 93b1f804. The offline suite's failures and errors are identical to the merge base.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Independent follow-ups 2–4 (relayed): Codex, codex exec -s read-only, static reviews of detached snapshots.

  • 93b1f804..771d75ac: FINDINGS (3).

    1. The fsspec glob caveat missed two cases: open_files() globs a scalar string that contains *, and fsspec.open(expand=True) passes a list.
    2. The s3_copy_pairs() docstring deferred the check of path2 itself for every source; that holds only for string sources.
    3. The guide said every method raises; mv(p, p) and invalidate_cache(p) do not.

    Docs and docstring fixed in 2fc8520f.

  • 771d75ac..2fc8520f: FINDINGS (5).

    • Four concern the precision of the fsspec glob caveat (write/append modes, open_expand) and that glob() reads the bucket spelling as a pattern.
    • One concerns _conflict_lookups() parsing an exact destination: it still raises ValueError before any write.

    6bda2250 replaced the list of fsspec modes and says that glob() reads the bucket spelling as a pattern.

  • 2fc8520f..6bda2250: FINDINGS (3).

    1. open_files(..., "wb") names partition files below the path, and FSMap.__delitem__ wraps ValueError in KeyError. Together with the earlier glob cases, these show that the composition sentence of the docs, which predates this PR (fc8c0cf docs/filesystem.md:731), does not hold for every fsspec mode. 12b4a5db restores it as it was, apart from the root-key sentence. The fsspec cases are recorded for (a) on Parse caller-supplied S3 paths with one parser in every filesystem method #1491.
    2. Rejected: S3PathPairing("bucket/src/", "bucket/out?versionId=v1", recursive=True) with sources src and src/k raises while pairing. Writing below a versioned path raises Cannot copy to a versioned file. on the merge base too (at cp_file()). The docstring statement about the exact destination of a string source still holds for that pair.

Since 771d75ac, only docs and one docstring changed. just lint and just docs lint pass at 12b4a5db.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Rebase and independent follow-up (relayed)

The branch was rebased from fc8c0cf onto master ce72fcc, which adds #1538, #1541, #1548 and #1532, and pushed with --force-with-lease.

Upstream changes that touch the grammar: only #1510's filter (s := S3Path.of(p1)).key or s.version_id and #1510's _copy_file lookup of the parsed source.

Differential check, rebuilt on ce72fcc. The two merge-base runs are identical. Against both, the branch has 1,083 expected differences, 0 unexpected and 0 missing. There is one new expected row: cp_file of key?version_id=/, which since #1510 looks up the key key?version_id=/ instead of version / of key.

Tests: just test offline at 74353d27 gives 4,252 passed. The Draft CI (lint, check, offline ×2) passes.

Independent follow-up: Codex, codex exec -s read-only, static review of the range-diff and of how the change composes with #1510 (filter order vs root parsing, empty pairs, list and S3Path sources, the replaced test). Result: CLEAN.

Comment thread docs/filesystem.md Outdated
also where `*`, `?` or `[` occur before the query: `rm("s3://YOUR_S3_BUCKET/key?versionId=")`
deletes only the key `key?versionId=`.
A bucket path with a version, such as `s3://YOUR_S3_BUCKET?versionId=v1` or
`s3://YOUR_S3_BUCKET/?versionId=v1`, is not an S3 path: the methods that read it raise

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Design consultation (Codex + Claude Fable 5.2, same neutral package) and decisions — maintainer: proceed with the recommendations.

  • D1 copy/mv into a directory named …?versionId=/: both → fix here (option 1). Done; Codex's caution adopted: string destinations stay strings when unambiguous (4.x backport, cp_file callers).
  • D2 non-recursive expand_path() of a bucket path with a version: Codex → reject versioned candidates here; Fable → leave to (a). Adopted Codex's narrow form (only the paths with a version ID are parsed; general literal validation stays with (a)), which also makes the docs statement hold.
  • D3 isfile() returns False for invalid paths: both → no change here (fsspec's except Exception; affects every invalid path). Fable: override isfile to catch OSError only, master-only in (a) → recorded on Parse caller-supplied S3 paths with one parser in every filesystem method #1491. Docs (this line) now state that isfile() returns False.
  • D4 lexical helpers vs bucket versions: Codex → fix the cache eviction here, keep helpers lexical; Fable → no change needed (over-eviction only). Adopted Codex's narrow cache fix (s3_cache.py), helpers unchanged (they retire with (a)).
  • D5 S3Path model accepts a keyless version / slash-only version ID: both → not here; keyless version validation is a master-only model change (Codex: separate issue; Fable: part of (a)) → recorded on Parse caller-supplied S3 paths with one parser in every filesystem method #1491 for (a); slash-only version_id stays opaque (normalizing would read the current object).

laughingman7743 and others added 10 commits November 30, 2026 01:56
S3Path.parse() follows the rule of GH-1481 that _strip_protocol() already
applied: a query whose version ID is empty or has only slashes names no
version and is part of the key, so "key?versionId=/" no longer names the
version "/" of "key" in the methods that parse the path as given.

A version ID query is read only after a key: "bucket?versionId=v1" and
"bucket/?versionId=v1" raise ValueError instead of naming a version of the
bucket path, while "bucket//?versionId=v1" stays the version v1 of the key
"/".

A path that ends in the form of a version ID query, also with an empty or
slash-only ID, is not a glob pattern, so rm(), mv(), copy(), cat(), get()
and expand_path() no longer expand its "?": rm("s3://bucket/key?versionId=")
deleted "keyXversionId=" as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…() (GH-1491)

rm() rejected "bucket//?versionId=v1" as the bucket, while rm_file() and
mv() address the version v1 of the key "/": a path with a version is
deleted as given and never stripped to the bucket by expand_path().

S3Path.PATTERN keeps its form, and parse() rejects the bucket path with a
version that it matches, instead of a second copy of the query grammar in a
lookahead.

The docs state that a path ending in a query that names no version is not
a glob pattern also where wildcards occur before the query, and that the
listed name of a key such as "?versionId=v1" at the bucket root raises when
passed back. The tests check that mv() deletes what it copied and drop the
duplicate and repeated cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A path with a version names an object, so is_bucket answers it, and rm()
asks it alone. The ls(), find() and chmod() checks for a version drop the
key condition that only a bucket path with a version needed, which parse()
no longer returns. The mv() test reads the copies with s3_copy_targets().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ersions there (GH-1491)

copy() and mv() into a directory whose name ends in a query that names no
version, such as key?versionId=/, joined the source name to the string,
which parsed as the version "/k" of "key". A destination named below a
string path2 is now path2 parsed with the suffix added to its key, kept as
the string when that string names the same path. A bucket path with a
version as path2 is rejected there; a list of sources was moved below it as
the key "?versionId=v1/..." and deleted.

expand_path() parses the paths with a version ID, so a bucket path with a
version raises as in the other methods. invalidate_cache() of the listed
name of a key at the bucket root, such as bucket/?versionId=v1, evicts that
name only, not the other spellings of the query. S3Path.is_bucket stays
True for a path without a key. The docs name a version ID for setxattr()
and state that isfile() returns False for an invalid path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ucket cases (GH-1491)

s3_copy_pairs() parses path2 only for a destination named below it or for
an S3Path source, so the contents of a directory copied to path2 itself
keep the destination that copy_pairs() names, which cp_file() checks.

Tests cover a string source copied into a directory at the bucket root
whose joined string is no S3 path, is_bucket of a path without a key, and
rm() of a bucket path with a version. The docs state the exceptions of
cat_ranges() and isfile(), the glob expansion of a list in
fsspec.open_files(), and the string path2 that s3_copy_pairs() needs to
return S3Path destinations; the expand_path() docstrings name the
ValueError of a path with a version ID.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…H-1491)

The docs name both glob expansions of fsspec.open_files() (a string with
"*", and each path of a list with expand=True, which fsspec.open() uses
when expanding) and limit the ValueError of a bucket path with a version to
the methods that read it, besides invalidate_cache(), which invalidates the
listed name of a key at the bucket root. The s3_copy_pairs() docstring
defers the check of path2 itself only for a string source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…H-1491)

Instead of listing the modes in which fsspec.open_files() expands a path
as a glob pattern, the docs say that the compositions name the version
where fsspec does not expand the path. glob() reads a bucket path with a
version as a pattern, and s3_copy_pairs() does not parse the destination
of a string source that is path2 itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The qualifier about fsspec's glob expansion is removed; how fsspec's
compositions read such names is recorded for the entry point work on the
issue instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant