Repository navigation
Release wheel check: refuse extra directory entries and over-cap wheels, hash members as they are read, and catch RecursionError in the index checks (opensoft/openRepoTools#352 items 1 to 3) - #23
Conversation
…heel check, hash each member as it is read, and catch RecursionError in the index checks Fixes items 1 to 3 of opensoft/openRepoTools#352, the sourcery-ai threads on #12. Item 4 is not here. 1. Directory entries. The wheel check's inventory dropped every name ending in "/", so an extra directory entry in the release wheel was never seen. The inventory now keeps them: one is allowed only where it is a parent directory of a file the wheel may hold (a tracked module, the stamp, a force-included payload file, or one of the five .dist-info names), and any other is refused with a named ::error:: line. hatchling 1.27.0 writes no directory entry (a wheel built from HEAD with it lists 32 members and none), so a normal release still passes. 2. Memory. The read loop kept every member's bytes until the end. The members' declared file_size values are now summed before anything is read, and a wheel over MAX_UNCOMPRESSED (256 MiB, about seventy times today's 3.6 MB wheel) is refused with a named ::error:: line, unread. Each member is then read in 1 MiB chunks and hashed, and its bytes are dropped: only the stamp, METADATA and entry_points.txt, which the check parses, are kept whole. The byte-for-byte comparisons against the commit's blobs (payload files, modules, licenses/LICENSE) compare sha256 digests, and every existing check keeps its meaning and its message. 3. RecursionError. A deeply nested index answer made json.loads raise RecursionError, which none of the four handlers named, so the step ended in a traceback. It joins the exception tuple of each of the four handlers (the testpypi and pypi jobs' empty-index and served checks), so the step ends with its named ::error:: refusal. tests/test_release_workflow.py: four refused directory entries (one that only starts a parent's name among them), a wheel with every parent directory listed that passes as the wheel without them does, a wheel over the cap by one member and by the sum (refused unread: a bad CRC in the same wheel is never named), and a 100,000-deep JSON answer at each of the four index checks. Lane: openRepoTools-3 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Reviewer's GuideConfigurationUpdate the release wheel check to reject unexpected directory entries, enforce an aggregate uncompressed-size cap and supported compression methods before reading, and hash members incrementally while retaining only parsed files.
Include RecursionError in the JSON refusal handlers for the empty-index and served checks in both release jobs.
TestsAdd wheel fixtures and checks for allowed and refused directory entries, over-cap wheels, and unsupported compression methods, including assertions that refusal happens before reading members.
Add interpreter-aware tests for deeply nested JSON answers across the four index checks, verifying a named refusal without a traceback.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
…D before reading, test RecursionError for itself, and fix the review's comment nits Fix round for #23, on lane 3's review of e7ec834 (items 1 to 3 of opensoft/openRepoTools#352). 1. The memory bound of item 2 held for STORED and DEFLATED members only. CPython's zipfile decompresses a BZIP2 or an LZMA member with no limit and cuts the result to the declared size afterwards, so a 2 KB BZIP2 member padded with 300 MB of zeros declared 4,322 bytes, passed the 256 MiB cap and the old check, and took about 600 MiB. The wheel check now refuses every member whose compression method is not STORED or DEFLATED, with "<name> in the wheel cannot be read (compression method N, ...)", before any member is read, beside the cap. With that member the peak is 36 MiB and the step exits 1 naming it. hatchling 1.27.0 writes method 8 only, so a real wheel still passes (re-checked on a wheel built with it: methods [8], 32 members, exit 0). The comment above the cap and the step's header say exactly what is bounded. lzma.LZMAError stays in the read loop's tuple, though no member reaches it now. 2. Three comment lines over 80 columns are rewrapped, and the two comments that read the unqualified issue references now say opensoft/openRepoTools#278 and opensoft/openRepoTools#352. tests/test_release_workflow.py: a BZIP2 member, an LZMA member and a member in method 99 are refused by their method and named, and a bad CRC in the same wheel is never reported (so no member was read first). The nested index answer is now 100,000 [ closed by 100,000 ], which is valid JSON, and each of the four cases asks for RecursionError in the refusal's line, so a plain ValueError no longer passes them. The split issue reference in the NESTED comment is joined. Lane: openRepoTools-3 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…r that runs the step: RecursionError up to Python 3.13, the wrong-shape refusal after CI for #23 failed at 8510181 in tests-shard (pytest-3) on the four nested-JSON cases only. CI runs CPython 3.15.2, where json.loads of 100,000 balanced brackets no longer raises RecursionError (CPython bounds the C decoder's recursion by stack depth there): it decodes a nested list, and the step refuses its wrong shape with its named line, "is not its JSON API's (TypeError: list indices must be integers or slices, not str)". That is the right behaviour, so release.yml is unchanged. On the 3.12.3 used here the same input raises RecursionError. The expectation of those four cases (the empty-index and the served check, in both upload jobs, ids unchanged) now follows the interpreter. The index steps run the python3 on the step's PATH, which is not always sys.executable (only the wheel check's heredoc runner uses that), so nested_refusal probes that python3 with json.loads of NESTED: where it raises, the case requires "(<the error>:" in the ::error:: line, as "(RecursionError:" did; where it decodes the list, it requires "is not its JSON API's". Either way each case still requires exit 1, no Traceback, and that the whole output is the one named ::error:: line. NESTED stays balanced, and a comment says why the expectation depends on the interpreter. Lane: openRepoTools-3 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days. You can request another review in 5 days and 10 hours by commenting |
…h its own message (SonarCloud python:S9073) SonarCloud's gate passed on #23 at d23268d and reported one new MAJOR issue from it: python:S9073, "Split this composite assertion into separate assertions", on a_directory_entry's change() in tests/test_release_workflow.py. The one assert that held two conditions, `entry.endswith("/") and entry not in members`, is now two: one that the case's name ends in "/", and one that the entry is not already in the wheel, each with its own message. Nothing else changes. Lane: openRepoTools-3 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
…L names, name a bad TestPyPI answer in the fetch, and count the macOS rerun's lines in the contract's form (opensoft/openRepoTools#352 items 4 to 6) (#26) Item 4 of opensoft/openRepoTools#352 and its follow-ups 5 and 6, from the sourcery-ai threads on release.yml's wheel and index checks (#12) and 006's macOS rerun (opensoft/openRepoTools-spec#11). Items 1 to 3 landed in #23. - The build job's wheel check holds a wheel to the layout zipfile writes, from byte 0 to the end of its end record. Each member's local header repeats its central entry's fields, the members follow one another with nothing between them, and the central directory and end record end the file with no extra field or comment. Each member's data must give exactly its declared size and CRC-32. Bytes no member declares, a local header that disagrees with its central entry, a directory entry that holds bytes, and a name with a NUL byte are each refused in one ::error:: line (follow-up 5). - The install job's TestPyPI fetch names an answer that is not TestPyPI's JSON in one ::error:: line instead of a traceback, and fetches nothing (follow-up 6). - The macOS rerun counts only lines of the contract's exact form toward its 16, so a line naming another file, or carrying more after "(unchanged)", no longer counts (item 4). - The review's fix round reads the last central record's name, extra field and comment lengths from the directory's own bytes. It ends a directory entry at a negative offset in an ::error:: line, not a traceback, and it names a name flagged UTF-8 that is not UTF-8 and a version needed to extract above 6.3. Lane openRepoTools-3's independent review read READY at 5a175f3, with no MUST. Its two SHOULDs and its NIT 3 are fixed at e0e9278 with six new cases, each failing before the fix, and lane openRepoTools-3 checked that delta. All 14 checks are green at e0e9278, tested on main ecd1bce. It lands under Brett Heap's standing landing word for lane 3's own fixes, typed in lane 3's session on 2026-11-10. Fixes opensoft/openRepoTools#352 Lane: openRepoTools-3 Co-Authored-By: Claude Opus 5.5 <[email protected]>



Lane: openRepoTools-3
Claim: opensoft/openRepoTools#352 (comment)
Fixes items 1 to 3 of opensoft/openRepoTools#352: the release wheel and index checks in
.github/workflows/release.yml, from sourcery-ai's threads r4506270224, r4506270229 and r4506270238 on #12. Item 4 is not here: it waits for the open spec PR that edits 006'sworkflows.md.What each fix does
/, so an extra directory entry was never seen. It now keeps them. A directory entry is allowed only where it is a parent directory of a file the wheel may hold (a tracked module, the stamp, a force-included payload file, or one of the five.dist-infonames). Any other is refused with a named::error::line. hatchling 1.27.0, the pinned backend, writes no directory entry: a wheel built from this repository's HEAD with it lists 32 members and none, and passes the check, so a normal release is not refused.file_sizevalues are summed before anything is read, and a wheel overMAX_UNCOMPRESSED(256 MiB; today's wheel declares about 3.6 MB, so the cap is some seventy times that) is refused unread with a named::error::line.NAME in the wheel cannot be read (compression method N, ...). The reason: CPython'szipfiledecompresses BZIP2 and LZMA members with no limit and cuts the result to the declared size afterwards, so for them the declared size, and so the cap, bounds nothing. hatchling 1.27.0 writes method 8 (DEFLATED) only: a wheel built with it has methods[8]and passes.zipfilereturns no more than such a member declares, so memory is one chunk plus the three members kept whole (the stamp,METADATAandentry_points.txt, which the check parses), and the cap bounds those three.licenses/LICENSE) compare sha256 digests. Every existing check keeps its meaning and its message.json.loadsraiseRecursionError, which none of the four handlers named, so the step ended in a traceback. It is now in the exception tuple of each of the four handlers (the empty-index check and the served check, in the TestPyPI and the PyPI job), so the step ends with its named::error::refusal.Tests added (
tests/test_release_workflow.py)::error::line (one with nothing under it, one that only starts a parent's name, one below the payload with no file, one of another version's.dist-info), and a wheel with every parent directory listed passes and prints what the wheel without them prints.::error::line and noTracebackat each of the four index checks. Which line depends on the interpreter that runs the step: withRecursionErrorin it wherejson.loadsraises it (the 3.12.3 used for the runs here), and "is not its JSON API's (TypeError: ...)" where it decodes the nested list (CI's CPython 3.15.2). The case probes thepython3the step runs and expects accordingly.Review fix round
Lane 3's review of
e7ec834found item 2's bound false for BZIP2 and LZMA: a 2 KB BZIP2 member padded with 300 MB of zeros, declaring 4,322 bytes, passed that head and took about 600 MiB. With the method refusal the same wheel exits 1 naming the member at 36 MiB, and a DEFLATED one of the same shape passes at 36 MiB. The review's comment nits (three comment lines over 80 columns, two unqualified#278, a split reference) are fixed too. Two things the review logged for later are not in this PR: a member's bytes past its declared size, and the TestPyPI fetch step'sjson.load.CI fix
CI at
8510181failed on the four nested-JSON cases only: CI runs CPython 3.15.2, wherejson.loadsof the nested answer decodes a list instead of raisingRecursionError, so the step refused its wrong shape with its named line. That is the right behaviour, sorelease.ymlis unchanged. The test now follows the interpreter (see Tests added).Narrow run
TMPDIR=/tmp XDG_STATE_HOME=/tmp/l3-352 timeout 3600 bash tests/run.sh -k 'test_release_workflow or repo_hygiene', run once on the committed tree of the head (b69a8b1) with the pinned openRepoShape submodule initialized:797 passed, 18 skipped, 3255 deselected in 58.04s, exit 0. The earlier heads' runs:d23268d,797 passed, 18 skipped, 3255 deselected in 59.76s;8510181,797 passed, 18 skipped, 3255 deselected in 59.93s;e7ec834,794 passed, 18 skipped, 3255 deselected in 75.38s (0:01:15). The headb69a8b1only splits one composite assertion in the tests'a_directory_entryinto two (SonarCloud python:S9073).release.ymlstill parses as YAML (PyYAML 6.0.3, four jobs).This is a draft: it leaves draft only after lane 3's independent review, and it lands only on Brett's word.
🤖 Generated with Claude Code