Skip to content

Release workflow: hold the wheel to its declared layout and refuse NUL 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

Merged
brettheap merged 3 commits into
mainfrom
fix/352-followups-5-6
Nov 10, 2026

Conversation

@brettheap

@brettheap brettheap commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openRepoTools-3
Claim: opensoft/openRepoTools#352 (comment)

Item 4 of opensoft/openRepoTools#352, and follow-ups 5 and 6, logged in lane 3's comment 6756663731. The branch is on code main 3460f5e (#23, items 1 to 3). Two commits: 1734304 is 5 and 6, and 5a175f3 is item 4. Code main is now ecd1bce. Its three new commits touch neither file, and the branch merges onto it cleanly.

A third commit, e0e9278, is fix round 1 from the independent review: SHOULD 1 (the last central record's name, extra field and comment lengths are read from the directory's own bytes, so a wheel declaring a longer name, an extra field or a comment with no byte behind it is refused), SHOULD 2 (a directory entry at a negative offset ends in an ::error:: line, not a traceback) and NIT 3 (a name flagged UTF-8 that is not UTF-8, and a version needed to extract above 6.3, are named, so the "Met, and not fixed here" note below no longer holds). Six new cases, each failing on 5a175f3's release.yml and passing on this head.

The defects

  1. The macOS rerun (Follow-ups from the sourcery-ai threads on W2's picks: release.yml's wheel and index checks (code#12) and 006's macOS rerun (spec#11) openRepoTools#352's body, from The 006 contracts say that both wheel checks hold a payload file to the commit's whole mode, that release.yml's checks refuse with a named ::error:: line, and what the macOS rerun's two --install runs do (closes opensoft/openRepoTools#278) openRepoTools-spec#11's review): the contract asks for a bin directory of its own and 16 placements under bash 3.2. Checked against the 006 workflows contract as The 006 workflows contract describes tests.yml as opensoft/openRepoTools-code#22 leaves it: tests and tests-no-submodule are gates over a matrix of shard jobs, and the Held-by list names each assertion (opensoft/openRepoTools#77) openRepoTools-spec#18 leaves it (e6eaa3c, install step 6): the rerun exists, and since release.yml's wheel checks disagree on a member's mode, its corrupt-member and index checks end in tracebacks, and its macOS rerun places none of the 16 commands under bash 3.2 openRepoTools#278 (b373ccc, 9ed4734) it already has a fresh HOME, a bin directory of its own holding a copy of pipx's link, the 3.2 check and a second --install. What still differed was its two counts. They took any line holding : installed at $bin_dir/, and any holding : already installed at $bin_dir/ and (unchanged). The contract asks for 16 lines of the form <file>: installed at <that directory>/<file>, then 16 of the form <file>: already installed at <that directory>/<file> (unchanged).
  2. Hidden bytes past a member's declared size, and NUL names. zipfile finds a member through the central directory, cuts it at its declared file_size, checks the CRC of that part only, and reads nothing of its local header but the name. So a wheel could carry bytes the build job's wheel check never read: past a member's declared size, between members, after the end record, or in a directory entry. A reader that walks the local headers could find other files. A name with a NUL byte passed as the part before the NUL.
  3. The install job's TestPyPI fetch step read json.load(handle)["urls"] with no handler and no ::error:: line, so a bad answer ended in a traceback. It failed closed.

The fixes

4: the macOS rerun, release.yml:1755.

  • Both counts go through exact (release.yml:1804), an awk count of lines that are exactly <command>: <said> $bin_dir/<command><after>: one command named on both sides and nothing more. The placed count is at release.yml:1811, and the unchanged count at release.yml:1827.
  • A line naming another file at the end of its path, or with more after (unchanged), is no longer one of the sixteen.
  • The refusal lines are unchanged:
    • ::error::--install under /bin/bash <version> placed <n> commands in <bin_dir>, not all 16
    • ::error::the second --install under /bin/bash <version> found <n> commands already installed and unchanged in <bin_dir>, not all 16
  • The step's comment (release.yml:1750) says so.
  • actionlint 1.7.12 with shellcheck 0.9.0 reports nothing on this file or on main's. The awk uses only POSIX index, substr and ENVIRON. It is checked with mawk here; macOS's BSD awk is not tried.

5: the wheel check, .github/workflows/release.yml.

  • unaccounted (release.yml:986) runs once every member has been read (release.yml:1120). 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's cap, method allow-list and read loop are unchanged, and run first.
  • It holds the wheel to the layout zipfile writes, from byte 0:
    • each member's local header has its central entry's fields again (signature, version, flags, method, time, date, CRC-32, sizes, name bytes), with no extra field;
    • the members follow one another with nothing between them;
    • after the last member come the central directory, with no extra field or comment, then the end record, with no comment, ending the file;
    • zipfile must have read the directory from where that record puts it (start_dir).
  • unlike_declared (release.yml:944) reads each member's data raw, a MiB at a time:
    • a stored member must be exactly as many bytes as it declares;
    • a deflated member must be one stream that ends at its last compressed byte;
    • either must give exactly its declared size and CRC-32;
    • it stops at most a MiB past the declared size.
  • A directory entry must hold no data, and a name with a NUL byte is refused.
  • Why it is sound: every byte of the wheel is then a header field, a name, or data that gives exactly what the check hashes. The comment at release.yml:910 says so.
  • What it cannot see:
    • the value of a field nothing else checks: the version, flags, time and date both headers agree on, and the central fields with no local twin (version made by, disk, internal attributes, external attributes beyond a payload file's mode). That is a few bytes per member;
    • a deflate stream's own encoding: padding bits no inflater reads.
    • Neither reaches an installed file.
  • A real wheel passes: two local hatchling 1.27.0 builds, TestPyPI's 1.1.0rc1 and PyPI's 1.1.0 (digests checked) all give no problem.
  • Each refusal is one ::error:: line:
    • release.yml:996: the wheel names a member '<name>', with a NUL byte, which zipfile and pip read as '<cut name>'
    • release.yml:999: <name> is a directory entry in the wheel, and holds <n> bytes
    • release.yml:1002: the wheel holds <n> bytes from byte <at> that no member declares, before <name>
    • release.yml:1005: <name> begins at byte <offset>, inside the member before it, which ends at byte <at>
    • release.yml:1022: <name>'s local header disagrees with its central directory entry on its <fields>
    • release.yml:1027: <name>'s data in the wheel is not exactly what it declares: <why>. The why is one of: it inflates past its declared size; it is stored in a size other than its declared one; its stream ends early; its stream does not end; its stream breaks; or a size or CRC-32 differs.
    • release.yml:1043: the wheel's <n> bytes after its last member are not exactly its central directory, with no extra field and no comment, then its end record, with no comment

6: the fetch step, release.yml:1563.

  • The URL is now one variable, used by curl and passed to the script.
  • The read, the selection and urlsplit are under one handler (release.yml:1579). It catches ValueError, KeyError, TypeError, AttributeError and RecursionError, the index checks' tuple. It exits 1 with:
    ::error::TestPyPI's answer for <url> is not its JSON API's (<Error>: <message>), so no wheel is fetched
  • The step's two other refusals (release.yml:1583, release.yml:1586) now carry ::error:: too.

Tests (tests/test_release_workflow.py)

Item 4:

Items 5 and 6:

  • test_release_build_the_wheel_check_refuses_a_wheel_not_laid_out_as_it_declares (:2685) covers eight wheels (LAID_OUT_WRONG, :2668), each built in the test:
    • bytes past a deflated member's declared size;
    • bytes past a stored member's declared size;
    • a local header whose size disagrees with the central directory;
    • a local header whose method disagrees with the central directory;
    • a NUL byte in a name;
    • bytes between two members;
    • bytes after the end record;
    • a directory entry that holds bytes.
  • Each wheel first passes zipfile.testzip(). The step then exits 1 with no traceback, and its only ::error:: line is the exact one expected.
  • test_release_install_check_the_fetch_names_an_answer_that_is_not_testpypi_s_json (:4571) covers three answers: not JSON, no urls, and nested 100,000 deep. The whole output must be the one exact ::error:: line, and nothing is fetched.
  • The nested case asks the interpreter (nested_fetch_error, :4550). It accepts RecursionError (3.12) or the TypeError of indexing a decoded list (3.15), as d23268d did.
  • The existing fetch refusals now also assert one ::error:: line.
  • damage's directory walk and rewrite became the shared helpers central_records, central_record and rewritten, with the same effect. run_fetch holds the fetch test's setup.
  • Before the fix, all 11 new cases fail against main's release.yml.
  • Run in-process before the suite run, the 36 existing wheel-check and fetch cases still pass, and so do the macOS rerun's line-for-line test and the release.yml's wheel checks disagree on a member's mode, its corrupt-member and index checks end in tracebacks, and its macOS rerun places none of the 16 commands under bash 3.2 openRepoTools#278 rerun test.

Narrow run (TMPDIR=/tmp XDG_STATE_HOME=/tmp/l3-352b timeout 3600 bash tests/run.sh -k 'test_release_workflow', on 5a175f3):
571 passed, 3722 deselected in 119.05s (0:01:59), exit 0.

Met, and not fixed here: the wheel check's zipfile.ZipFile(...) handler catches OSError and BadZipFile only. A central name flagged UTF-8 that is not UTF-8 raises UnicodeDecodeError, so it ends in a traceback. That predates this PR and fails closed.

Fixes opensoft/openRepoTools#352: its items 1 to 3 landed in #23, and this PR does item 4 and follow-ups 5 and 6.

🤖 Generated with Claude Code

Summary by Sourcery

Harden release validation by enforcing wheel layout integrity, making TestPyPI fetch failures explicit, and matching macOS reinstall output to the contract exactly.

Bug Fixes:

  • Reject wheels containing undeclared, overlapping, malformed, or trailing bytes, inconsistent local and central headers, data-bearing directory entries, or NUL-containing names.
  • Report malformed TestPyPI JSON responses and fetch validation failures as concise GitHub Actions errors without tracebacks.
  • Require macOS reinstall checks to count only output lines matching the declared installation contract exactly.

Enhancements:

  • Harden the release workflow's wheel validation and improve diagnostics for wheels it cannot open or walk.

Tests:

  • Add coverage for malformed wheel layouts, unreadable wheel metadata, invalid TestPyPI responses, and strict macOS rerun output counts.

brettheap and others added 2 commits November 10, 2026 12:27
…yte and refuse NUL names; name a bad TestPyPI answer in the install fetch (opensoft/openRepoTools#352 follow-ups 5 and 6)

Follow-up 5 of opensoft/openRepoTools#352. zipfile finds a member
through the central directory, cuts it at its declared size, checks the
CRC of that part alone, and reads nothing of its local header but the
name; a name with a NUL byte it reads as the part before the NUL. So a
wheel could carry bytes the check never read: past a member's declared
size, between members, after the end record, or in a directory entry,
and a reader walking the local headers could find other files.

The build job's wheel check now also runs `unaccounted` once every
member has been read: from byte 0, each local header must be its central
entry's fields again (signature, version, flags, method, time, date,
CRC-32, sizes, name) with no extra field; each member's data must be
exactly its declared compressed bytes, a stored member as many as it
declares and a deflated one a single stream ending at their last byte,
giving exactly its declared size and CRC-32 (`unlike_declared`); the
members must follow one another with nothing between them; and the
central directory, with no extra field or comment, then the end record,
with no comment, must end the file where zipfile read them. A directory
entry must hold no data, and a name with a NUL byte is refused. Each is
one named `::error::` line. #23's cap,
method allow-list and read loop are unchanged and run first. hatchling 1.27.0 wheels (two local
builds, TestPyPI's 1.1.0rc1, PyPI's 1.1.0) pass it unchanged.

Follow-up 6. The install job's "fetch the wheel from TestPyPI" step
read the answer with no handler. It now catches ValueError, KeyError,
TypeError, AttributeError and RecursionError as the index checks do,
and exits 1 with one `::error::` line naming the URL and the error; its
two other refusals now carry `::error::` too.

Tests: eight wheels not laid out as they declare, each read cleanly by
zipfile.testzip() and each giving exactly its one `::error::` line, and
three TestPyPI answers (not JSON, no `urls`, nested 100,000 deep, the
last taking RecursionError or the TypeError of a decoded list by the
interpreter). The fetch's existing refusals now assert one `::error::`
line. The CD-walking helpers `damage` used are shared, unchanged in
effect.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ommand>: installed at <its bin>/<command>`, then sixteen `... (unchanged)` (opensoft/openRepoTools#352 item 4)

Item 4 of opensoft/openRepoTools#352, "The macOS rerun is unchanged",
checked against the 006 workflows contract as
opensoft/openRepoTools-spec#18 left it (e6eaa3c on spec main, step 6 of
the install job). The rerun still exists, and since
opensoft/openRepoTools#278 (b373ccc, 9ed4734) it already has a fresh
HOME and a bin directory of its own holding a copy of pipx's link,
requires BASH_VERSION 3.2, and runs --install twice there. What still
differed from the contract was the two counts: they took any line
holding ": installed at $bin_dir/", and any holding ": already installed
at $bin_dir/" and " (unchanged)", where the contract asks for 16 lines
of the form `<file>: installed at <that directory>/<file>` and then 16
of the form `<file>: already installed at <that directory>/<file>
(unchanged)`.

Both counts now go through `exact`, an awk count of lines that are
exactly `<command>: <said> $bin_dir/<command><after>`: one command named
on both sides and nothing more. A line naming another file at the end of
its path, or with more after " (unchanged)", is no longer one of the
sixteen. The refusal lines are unchanged.

Tests: MACOS_RERUN_LINES names the new lines, so the rerun is still held
to the offline --install line for line. The new
test_release_install_check_the_macos_rerun_counts_only_the_contract_s_lines
runs the rerun with pipx's link pointing at FAKE_INSTALL, a stand-in
--install that prints the case's lines. Sixteen lines of the contract's
form each run pass. A placed line naming another file, and an unchanged
line with more after it, each exit 1 with the exact `::error::` line
naming 15; both passed under the old counts. The
opensoft/openRepoTools#278 rerun test over a real venv passes unchanged.

Lane: openRepoTools-3
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Configuration

Review the wheel-layout and member-data checks together with their invocation and error handling, which ensure the release check accounts for every wheel byte and rejects NUL names.

  • .github/workflows/release.yml L831-836, L910-1063, L1141-1147 (+2 small edits)

Review the TestPyPI fetch’s URL handling and error reporting together, so malformed answers and invalid file-host listings fail with a named error before any wheel is fetched.

  • .github/workflows/release.yml L1584-1589, L1594-1615

Review the macOS rerun’s exact-line counting logic together with its contract comment, ensuring only the required placement and unchanged lines count.

  • .github/workflows/release.yml L1777-1781, L1828-1838, L1854

Tests

Review the synthetic wheel builders and wheel-check cases together to verify malformed layouts, hidden data, NUL names, and wheels the checker cannot open or walk are refused as expected.

  • tests/test_release_workflow.py L2190-2222, L2549-2845 (+3 small edits)

Review the fetch-test setup and cases together to verify malformed TestPyPI answers and invalid listings produce one error and trigger no wheel download.

  • tests/test_release_workflow.py L4597, L4605-4623, L4654-4724

Review the macOS rerun’s updated line-for-line contract and its stand-in installer cases together to verify near-matching lines no longer satisfy either count.

  • tests/test_release_workflow.py L4898-4909, L5228-5325 (+2 small edits)

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

…m the directory, name a negative member offset, a bad UTF-8 name and an extract version above 6.3 (opensoft/openRepoTools#352)

Fix round 1 on the independent review of #26
(opensoft/openRepoTools#352 follow-up 5), its two SHOULDs and NIT 3.

SHOULD 1: zipfile reads the central directory as one buffer and cuts the
last record's name, extra field and comment at its end, so a last record
declaring a name 22 bytes longer, a 4-byte extra field or a 9-byte comment,
with no byte added, passed the whole step: `directory` summed what zipfile
kept, not what the record declares. pip installs such a wheel exactly as
checked; uv refuses it. `unaccounted` now walks the directory's own bytes
before it reads the end record, in zipfile's order, and a record whose name,
extra field and comment lengths are not (its name's bytes, 0, 0) adds `not
lengths` to the condition that already refuses bytes after the last member,
with that refusal's words unchanged.

SHOULD 2: `raw.seek(entry.header_offset)` crashed with OSError and a
traceback, and no `::error::` line, on a directory entry zipfile puts at a
negative offset (the end record's directory offset too far, so the bytes-
before-the-archive correction moves the one record not moved with it to
-1000). The call to `unaccounted` now catches OSError, ValueError and
OverflowError and names the problem, so the step prints an `::error::` line
and exits 1.

NIT 3 (older than the layout check): a name flagged UTF-8 that is not valid
UTF-8 ended in a UnicodeDecodeError traceback, and a version needed to
extract above 6.3 in a NotImplementedError one, as zipfile opened the wheel.
Each is now caught there and named in an `::error::` line, exit 1.

Six new cases, each failing against the release.yml of 5a175f3 and passing
against this one. Three go into LAID_OUT_WRONG (the last record's name 22
bytes longer, a 4-byte extra field, a 9-byte comment; with no bytes added: the
three exited 0 before). Three go into the new
test_release_build_the_wheel_check_names_a_wheel_it_cannot_walk_or_open
(a directory entry at offset -1000, a UTF-8 flagged name that is not UTF-8, a
version needed to extract of 6.4; each ended in a traceback with no
`::error::` line before). PyPI's 1.1.0 wheel, TestPyPI's 1.1.0rc1 wheel and
two hatchling 1.27.0 builds of 5a175f3 all still pass the layout check.

Lane: openRepoTools-3
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@sonarqubecloud

Copy link
Copy Markdown

@sourcery-ai

sourcery-ai Bot commented Nov 10, 2026

Copy link
Copy Markdown

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 4 days and 20 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@brettheap
brettheap merged commit b039fa4 into main Nov 10, 2026
14 checks passed
@brettheap
brettheap deleted the fix/352-followups-5-6 branch November 10, 2026 17:43
@brettheap

brettheap commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

R3 source-efficiency attempt remains failed; no queue admission or heavy run occurred.

  • PR65 head 99b2cee5974cd69b4b43cd87008aa6236b09209c, base bb253610a46d8f06d60b0b1c371102606cf70bdb.
  • Ordinary run 43495118330 reported snapshot-mismatch, fields ["merge_commit_sha"], stage source, then source-metadata and {mode:full,omit_full:false}. Only this coordinator-owned fallback run was cancelled; its terminal state is confirmed cancelled.
  • Independent fast run 43495118253 succeeded: 455 passed, 18 existing skips, 4788 deselected. Its tested merge b83a805094d72252ed3c1a29295e94dcfd0a40f0 has ordered parents bb253610a46d8f06d60b0b1c371102606cf70bdb and 99b2cee5974cd69b4b43cd87008aa6236b09209c; tree 01ea9d883a7699c23bc2b6042e1f14484f71a2a0.
  • The log proves the rejecting field, not the original raw event hint's value. No claim that the original value was null is made.

Under the owner's existing directly-related-repair approval, prepare a bounded source/candidate event comparison: hints may only be absent/null or equal the trusted tested SHA, with actual ordered Git-parent proof still mandatory. Unknown hints retain full even when both snapshots agree. Candidate bodies, admission, fast provenance, protection and subsequent raw live rereads remain strict. Red-first regressions and full ordinary/reusable qualification must precede checked normal merges and genuinely fresh source events.

No review-acceptance receipt or queue command has been posted for PR65. The unpublished B remains local. Running lanes, tools, assembly pins, settings, app access, paid service and releases stay unchanged.

Routing correction: this rollout belongs to opensoft/openRepoTools-spec#26, not this historical release PR. The same evidence is now posted on the governing spec issue; no release change is requested.

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.

Follow-ups from the sourcery-ai threads on W2's picks: release.yml's wheel and index checks (code#12) and 006's macOS rerun (spec#11)

1 participant