Skip to content

Name explicit versions in info() and record HeadObject's VersionId (GH-1529) - #1618

Merged
laughingman7743 merged 4 commits into
masterfrom
fix/1529-version-entries
Nov 30, 2026
Merged

laughingman7743 merged 4 commits into
masterfrom
fix/1529-version-entries

Conversation

@laughingman7743

@laughingman7743 laughingman7743 commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

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 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, the metadata from the response. S3Object.from_metadata() names and versions the entry from the looked-up path, as from_version() names a version, so _head_object() keeps no rules of its own; its version_id parameter goes. A lookup without a version, or with the null version, 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 as info() names it (bucket/key?versionId=<id> instead of bucket/key). Directories stay grouped by their key.
  • The cached lookup of a versioned path is separate from that of the key, so a later lookup of the key keeps the key's name.

Item 2. The HeadObject VersionId is recorded.

  • The entry of a HeadObject lookup records the VersionId that HeadObject returns, or else the requested version, also without version_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.
    • S3FileTarget resolution: the version that a read pins.

    No other code under pyathena/ reads an entry's version_id, and S3Object.to_api_repr() does not emit it. Entries listed with ListObjectsV2 keep their key sets and have no version_id key. So info()["version_id"] is None when info() 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. The created() docstring now points to S3Bucket.creation_date from core.list_buckets().

The guide's versioning section describes items 1 and 2.

Release notes (5.0.0):

  • The entry of an explicitly requested version other than null is named bucket/key?versionId=<id> by info(), and du(total=False) uses the same key.
  • info()["version_id"] holds the version that HeadObject returns, also without version_aware.
  • S3Object.from_metadata() takes no version_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.
  • Offline filesystem suite (/tmp/pyathena-1341/offline-test.sh -n 8 tests/pyathena/filesystem): 2249 passed.
  • New tests:
    • 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 records v1, and the GetObject requests of a filesystem that is not version-aware, as the client receives them, carry no VersionId.
    • The AWS test test_info_file expects the VersionId of the client's own HeadObject response, which is absent on an unversioned bucket.
  • Changed tests, to the decided contracts:
    • test_info_version_aware_heads_listed_file[False]: the looked-up entry records v1.
    • test_fan_outs_act_on_listed_keys[du-version]: the size is keyed bucket/a/x?versionId=v1.
    • test_info_looks_up_path_as_it_is: the key a/x?versionId=null with version_id="v2" is named bucket/a/x?versionId=null?versionId=v2, as ls(versions=True) names it.
  • Mutation check: dropping the naming, gating the recording by version_aware, ungating the reader of S3FileTarget, or keying du by the key each fails the matching tests.
  • Differential check: a 12-case matrix through the merge base (twice) and the head. For a plain and a versioned bucket, each with and without version_aware, it covers sync info (key, ?versionId=, version_id=), ls and du of a version and find; async _info; and a read after info. Result: the 4 versioned info rows change as expected (the recorded version and the versioned names, du included); the plain-bucket rows and every read row are unchanged.
  • Not run: live AWS tests (the CI AWS jobs run when Ready).

🤖 Generated with Claude Code

laughingman7743 and others added 2 commits November 30, 2026 22:19
…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>
Comment thread pyathena/filesystem/s3_object.py Outdated
version_id=version_id,
bucket=path.bucket,
key=path.key,
version_id=path.version_id or metadata.version_id,

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 (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.

Comment thread docs/filesystem.md
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.

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.

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's version_id" (grep in s3.py/s3_async.py: two readers, both gated); "to_api_repr() does not emit it" (_API_FIELD_TO_S3_OBJECT_FIELD has no VersionId); "a later lookup of the key keeps its name" (put_lookup keys 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,

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), 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 VersionId that HeadObject returned. The response's version is recorded first now, and the requested one only when the response has none (new test row unreported). This matches "the metadata from the response".
  • IR-3 (Medium, repaired). The AWS test_info_file compared info.version_id with 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 uses answer_s3_requests and checks the GetObject requests as the client receives them. Ungating S3FileTarget'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. The du() docstring now names directories as the listing does, not as info() 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.

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), 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>
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.

Settle the S3Object entries and response models for 5.0.0

1 participant