Repository navigation
Name explicit versions in info() and record HeadObject's VersionId (GH-1529) - #1618
Conversation
…H-1529) Items 1-3 of #1529 (5.0.0): - info() of a version other than "null" that the path or version_id names gives the entry the name bucket/key?versionId=<id>, as ls() and find() name a version; the name comes from the request and the metadata from the response, so a lookup without a version, or with the "null" version, keeps the name of its key. _ls_version() no longer renames, and du(total=False) names the size of such a version the same way. - The entry of a HeadObject lookup records the requested version, or the VersionId that HeadObject returns, also without version_aware. The readers that pin a read to it (the version-aware refresh of a listed file in _path_info and S3FileTarget's resolution) stay gated by version_aware. - The bucket entries keep their key set; created() of a bucket stays None, and its docstring points at S3Bucket.creation_date of core.list_buckets(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Self-review round one: from_metadata() names the entry after the looked up path and records its version or the reported one, as from_version() names a version, so that _head_object() keeps no rules of its own; its version_id parameter goes. The guide says that an entry listed with ListObjectsV2 has no version, and names the versioned spelling; the to_path() docstring and a stale comment no longer equate recording with pinning; a test row that repeated another test is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| version_id=version_id, | ||
| bucket=path.bucket, | ||
| key=path.key, | ||
| version_id=path.version_id or metadata.version_id, |
There was a problem hiding this comment.
Self-review round one (behavior and failure paths, framework contracts, simplicity and test quality). Base 059a3c67, head reviewed 2f0b2682, repairs in 961ea1c1. /code-review high ran as part of this round.
Inventory: S3Object.from_metadata and its one caller _head_object (sync, and async through it); _path_info, _ls_version, du, created; the readers of an entry's version_id (_path_info version-aware refresh, S3FileTarget resolution); the docs and the tests.
Result: FINDINGS. Repaired: R1-1 to R1-4. Kept as decided: R1-5. No change needed: R1-6. Afterwards: offline filesystem suite 2247 passed; the matrix shows the 4 expected differences; each repair mutation-checked.
R1-1 (repaired; this line). _head_object overrode the name that from_metadata gave and computed the version itself, which split the rules between the factory and its caller. from_metadata() now names and versions the entry from the looked-up path and the response, as from_version() names a version. Its version_id parameter goes, which the PR's release notes list.
| with the `null` version, is named after its key. The `version_id` of an entry looked up | ||
| with HeadObject is the requested version, or else the version that HeadObject reports, | ||
| also without `version_aware`, which alone pins reads to it. An entry listed with | ||
| ListObjectsV2, such as one that `info()` answers from a cached listing, has none. |
There was a problem hiding this comment.
R1-2 (repaired). The guide said that a listed entry has no version, but entries of ls(versions=True) have one. It now says ListObjectsV2. It also named the entry "the same name" as the path, although ?version_id= and similar spellings are normalized to ?versionId=; it now gives the form bucket/key?versionId=<id>.
R1-3 (repaired). The to_path() docstring and a comment in _head_object still equated a recorded version with a pinned one.
R1-4 (repaired). The current row of test_info_names_an_explicit_version repeated test_info_version_aware_heads_listed_file[False]'s evidence and is removed.
R1-5 (kept as decided; this line). Without version_aware, info()["version_id"] is the reported version after a HeadObject and None when info() answers from a cached ListObjectsV2 listing. #1529 item 2 decided to record HeadObject's version and to keep the key sets of listed entries, so the split by source is intended. The guide now states it.
R1-6 (no change). The live test_info_file asserts version_id is None for an unversioned path. That holds for the test environment's bucket, which is not versioned, and is the correct answer there.
Self-review round two (claims, callers, operator, evidence), full pass over the repaired head:
- Claims: "no other code under
pyathena/reads an entry'sversion_id" (grep ins3.py/s3_async.py: two readers, both gated); "to_api_repr()does not emit it" (_API_FIELD_TO_S3_OBJECT_FIELDhas noVersionId); "a later lookup of the key keeps its name" (put_lookupkeys an explicit version apart, and a test covers it). - Callers and operator: the requests are unchanged (matrix: no row adds or drops a request); only the entries' names for explicit versions and the recorded version differ.
- Evidence: offline only; the AWS jobs run when Ready.
Result: CLEAN for round two.
Independent review: the entry records the VersionId that HeadObject reports, or else the requested version; the non-pinning test checks the GetObject requests as the client receives them; the AWS info test expects the version that HeadObject reports; the guide limits the du() naming to a version in the path, and the du() docstring names directories as the listing does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| version_id=version_id, | ||
| bucket=path.bucket, | ||
| key=path.key, | ||
| version_id=metadata.version_id or path.version_id, |
There was a problem hiding this comment.
Independent review (relayed), round one. Reviewer: Codex CLI 0.172.0, gpt-6.2-astra, codex exec -s read-only, session 01a22ca2-d272-78b1-860d-35e10372ca05. Base 059a3c67, head 961ea1c1, detached snapshot. The prompt held the diff, the decision and the conventions, without the PR text or prior findings. Static review.
Covered (as reported): info(), _path_info, _head_object, cache lookup and eviction, the entry factories, ls/find/walk/du/glob, copy/move/download/delete planning, S3FileTarget, sync and async reads, and the remaining readers of name and version_id. It confirmed that both file implementations gate pinning on version_aware, that to_api_repr() excludes VersionId, that ListObjectsV2 entries omit version_id, that bucket entries keep their key set and created(bucket) is None, and that the changed tests distinguish the two revisions.
Result: FINDINGS, 3 Medium and 2 Low. Repaired in d7820f3b: IR-1, IR-3, IR-4, IR-5. Already covered: IR-2.
- IR-1 (Medium, repaired; this line). The requested version took precedence over the
VersionIdthat HeadObject returned. The response's version is recorded first now, and the requested one only when the response has none (new test rowunreported). This matches "the metadata from the response". - IR-3 (Medium, repaired). The AWS
test_info_filecomparedinfo.version_idwith the version of an unqualified path, which would fail on a versioned staging bucket. It now expects the version that HeadObject reports. - IR-4 (Low, repaired). The non-pinning test recorded requests at
S3Core.call(). It now usesanswer_s3_requestsand checks the GetObject requests as the client receives them. UngatingS3FileTarget's pinning fails it (checked). - IR-5 (Low, repaired). The guide implied that
du(version_id=...)names a version; only a version in the path does. Thedu()docstring now names directories as the listing does, not asinfo()does. - IR-2 (Medium, already covered). Removing
from_metadata(version_id=...)is a 5.0.0 API change, listed in the PR's release notes.
just lint and just docs lint pass; offline filesystem suite 2248 passed; the matrix shows the 4 expected differences only.
There was a problem hiding this comment.
Independent review (relayed), follow-ups. Codex CLI 0.172.0, gpt-6.2-astra, codex exec -s read-only, static. (1) Session 01a22cb0-a4d0-7e03-b558-d711b04cf765, range 961ea1c1..d7820f3b: two test findings: no case distinguished the precedence of the reported and the requested version, and the AWS expectation went through the same conversion as info(). Repaired in 01753da8: a reported-first row (request v1, report v2: name keeps v1, version_id is v2; the reverse precedence fails it, checked), and the AWS test reads VersionId from the client response. (2) Session 01a22cb7-8178-77d2-b497-5ebc208337b1, range d7820f3b..01753da8: CLEAN.
Independent review follow-up: a case requests v1 and gets v2 reported, so that the precedence is tested; the AWS test reads the expected VersionId from the client's own HeadObject response. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WHAT
The last part of the #1529 decisions: items 1–3. Master only (5.0.0).
Item 1.
info()names an explicit version.info()of a version other thannullthat the path orversion_id=names gives the entry the namebucket/key?versionId=<id>, asls()andfind()name a version.S3Object.from_metadata()names and versions the entry from the looked-up path, asfrom_version()names a version, so_head_object()keeps no rules of its own; itsversion_idparameter goes. A lookup without a version, or with thenullversion, keeps the name of its key, though HeadObject reports a version._ls_version()no longer renames the entry.du(total=False)names the size of such a version asinfo()names it (bucket/key?versionId=<id>instead ofbucket/key). Directories stay grouped by their key.Item 2. The HeadObject
VersionIdis recorded.The entry of a HeadObject lookup records the
VersionIdthat HeadObject returns, or else the requested version, also withoutversion_aware. Before, a filesystem that is not version-aware recorded None.The readers that pin a read to an entry's version stay gated by
version_aware:_path_info(): the refresh of a listed file that has no version to pin.S3FileTargetresolution: the version that a read pins.No other code under
pyathena/reads an entry'sversion_id, andS3Object.to_api_repr()does not emit it. Entries listed with ListObjectsV2 keep their key sets and have noversion_idkey. Soinfo()["version_id"]is None wheninfo()answers from a cached listing: this is the decided split by source, and the guide states it.Item 3. Bucket entries. They keep their key set, and
created()/modified()of a bucket stay None, as documented. Thecreated()docstring now points toS3Bucket.creation_datefromcore.list_buckets().The guide's versioning section describes items 1 and 2.
Release notes (5.0.0):
nullis namedbucket/key?versionId=<id>byinfo(), anddu(total=False)uses the same key.info()["version_id"]holds the version that HeadObject returns, also withoutversion_aware.S3Object.from_metadata()takes noversion_id; it reads the version from the looked-up path and the response.WHY
Closes #1529: items 1–3, after the #1491 grammar half (#1551) and #1561, as ordered on #1327. The other parts are #1585 (A), #1590 (C, item 5) and #1599 (item 4, B).
TEST
Tested commit: the head of this PR; merge base
059a3c67d8ef836fb41c9a903feaa4bb9b8fb628.just lint,just docs lint: pass./tmp/pyathena-1341/offline-test.sh -n 8 tests/pyathena/filesystem): 2249 passed.test_info_names_an_explicit_version[path-version, version_id, null-version, unreported, reported-first]: the name and the recorded version of each explicit lookup (the reported version first, the requested one when HeadObject reports none), and a later lookup of the key named after the key.test_read_without_version_aware_is_not_pinned: the entry recordsv1, and the GetObject requests of a filesystem that is not version-aware, as the client receives them, carry noVersionId.test_info_fileexpects theVersionIdof the client's own HeadObject response, which is absent on an unversioned bucket.test_info_version_aware_heads_listed_file[False]: the looked-up entry recordsv1.test_fan_outs_act_on_listed_keys[du-version]: the size is keyedbucket/a/x?versionId=v1.test_info_looks_up_path_as_it_is: the keya/x?versionId=nullwithversion_id="v2"is namedbucket/a/x?versionId=null?versionId=v2, asls(versions=True)names it.version_aware, ungating the reader ofS3FileTarget, or keyingduby the key each fails the matching tests.version_aware, it covers syncinfo(key,?versionId=,version_id=),lsandduof a version andfind; async_info; and a read afterinfo. Result: the 4 versionedinforows change as expected (the recorded version and the versioned names,duincluded); the plain-bucket rows and every read row are unchanged.🤖 Generated with Claude Code