Skip to content

publish: upload the snapshot as a paced draft so a secondary rate limit cannot stall it - #648

Merged
RyanTheTide merged 3 commits into
mainfrom
publish-paced-upload
Dec 5, 2026
Merged

RyanTheTide merged 3 commits into
mainfrom
publish-paced-upload

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

The release step of publish.yml uploads a testing snapshot (about 514 assets) in one gh release create. Since 2026-12-05 19:35 UTC GitHub's secondary rate limit refused it on every attempt while the organisation was busy: runs 47555497555 (three attempts) and 47567962407 signed the Aurora Nightly 2026-12-06.2 set (kernel-aurora 7.3.0-55 with linux#2989), then failed to publish it. gh-retry backs off for seconds, and after a failed create it re-uploads every file with --clobber, so it cannot get past a sustained limit.

scripts/gh-release-paced creates the release as a draft, or resumes the draft an interrupted run left. It uploads the files in batches of 40 with a 45 s pause. An asset is skipped only when GitHub reports it uploaded with the SHA-256 of the local file, so stale or unfinished (empty, starter) assets are uploaded again. Assets that are not in the directory are deleted from the draft. Names are compared the way GitHub stores them (aura-1.0.0~b19 becomes aura-1.0.0.b19, as asset_name in sign-repository.py). Every asset listing must succeed in full (a failed listing stops the script before any prune or publish). The draft is published, with the target set to this run's commit, only when every asset matches by digest. A published tag is refused. The plan step now refuses only a published release, so a new run resumes a draft (a draft has no tag yet, so next-tag.py picks its name again).

Tested: buildbox at 391550d: no runtime change on a Mac (CI workflow only). tests/test_gh_release_paced.py (fake gh: batches and publish, a secondary limit retried, a half-uploaded draft resumed, a stale same-name asset replaced, an unfinished empty asset re-uploaded, a stray asset deleted, GitHub name mapping, a published tag refused, an inventory that fails on every listing or only at the final check publishes nothing; the plan step's draft check) and test_gh_retry.py pass; tests/ 868 passed. Checked against the live API that gh release view --json databaseId,isDraft and the assets endpoint's state/digest fields have this shape.
Risk: two-way · no Mac (Fedora Testing publication only; a snapshot release takes about 10 minutes longer)

…it cannot stall it

A testing snapshot has about 500 assets. Since 2026-12-05 19:35 UTC every
`gh release create` of the Aurora Nightly 2026-12-06.2 snapshot was refused
by GitHub's secondary rate limit while the organisation was busy (runs
47555497555 and 47567962407, four attempts): collect and sign passed each
time, but the release step failed and gh-retry's fallback re-uploaded every
file again with --clobber.

scripts/gh-release-paced creates the release as a draft, uploads the files
in batches of 40 with a 45 s pause (each batch skips files the draft already
holds, so a rerun of the job resumes), checks that the assets match, then
publishes the draft. A tag that is already published is refused.

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
@RyanTheTide
RyanTheTide requested review from a team and DjDeveloperr as code owners December 5, 2026 23:21

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: FINISH at cd94856

Failure: The workflow cannot resume an existing draft when planning runs again. The successful gh release view check in .github/workflows/publish.yml:129–131 exits with "Release ... already exists" for drafts as well as published releases. Replaying those exact lines with the PR's existing draft fixture returned 1 before the uploader could resume.

Failure: scripts/gh-release-paced:19–31 trusts an existing name as a completed upload and compares only names before publishing. With the PR's fixture seeded with a same-name, same-size stale RPM, the script returned 0 and published the release, while the newly uploaded SHA256SUMS failed for that RPM. The same path published an empty existing asset. GitHub documents that a failed upload can leave an empty asset in the starter state. Compare uploaded state and content digests before skipping or publishing. Keep the refusal for published tags.

Checked: All ten existing paced-release and retry tests passed. The three reproductions used their existing fake release state and the exact script and workflow fragment. No live release was created.

Review of the paced upload (App review on cd94856):
- The plan step refused any existing release, so a run after an
  interrupted release step stopped at the draft it left. It now refuses
  only a published release and lets the release step resume a draft.
- gh-release-paced skipped an asset by name only, so a stale or unfinished
  (empty, state "starter") asset could be published. It now skips an asset
  only when GitHub reports it uploaded with the SHA-256 of the local file,
  uploads anything else again, deletes assets that are not in the
  directory, and publishes only when every asset matches by digest.
- Names are compared the way GitHub stores them (other characters become
  ".", as asset_name in sign-repository.py), so aura-1.0.0~b19 matches
  its asset aura-1.0.0.b19.
- The final edit sets the target, so a resumed draft is tagged at this
  run's commit.

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Addressed at bf69f42: the plan step resumes a draft and refuses only a published release; assets are skipped only when uploaded with a matching SHA-256 (stale and starter-state assets are uploaded again, stray ones deleted); names compared as GitHub stores them; publish only when every digest matches. Tests cover each case.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: FINISH at bf69f42

Failure: A failed paginated inventory can still publish an unverified snapshot. At scripts/gh-release-paced:44–51, the while ... done < <(remote) loop never receives the exit status of gh api --paginate. The retry wrapper emits the final attempt's partial stdout before returning a failure. I replayed a draft whose first page returned all 30 expected uploaded digests and whose second page failed with HTTP 503 on every retry while a stray RPM remained there. The exact helper returned 0 and ran release edit --draft=false with the stray RPM still attached. Check the inventory command's successful exit before using its output, including the initial prune and the final publish check.

Checked: All 17 existing paced-release and retry tests pass at this revision. Draft admission now works, published releases are refused, and a complete inventory causes stale same-size and starter-state assets to be replaced. The remaining failure is the partial inventory path in the new implementation.

@github-actions github-actions Bot added changes-requested A reviewer requested changes (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 5, 2026
@github-actions

github-actions Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Merge readiness at 391550d8: not ready yet

Check Detail
CI at head running running: check, vendor-policy (44), vendor-policy (45), repository-closure (44), repo-trust (44), fex-guest-default (44)
Review ok approved by aurora-silicon-review
Requested changes ok none
Hardware row at head ok not needed: no runtime change
Conflicts ok none
PR text ok Risk: two-way · no Mac (Fedora Testing publication only; a snapshot release takes about 10 minutes longer)

Areas: none matched in CODEOWNERS

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

App review on bf69f42: the inventory loops read `gh api --paginate`
through process substitution, which drops its exit status, and gh-retry
passes on the partial stdout of a failed last attempt. A listing whose
second page kept failing could therefore prune and publish from half an
inventory. Each listing is now captured first and a failed one ends the
script, before the prune, every batch and the final check. Tests cover a
listing that fails on every call and one that fails only at the final
check before publishing.

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Addressed at 391550d: every asset listing is captured first and a failed one (including partial pages then a 503) ends the script before the prune, each batch and the final check. Two new tests: a listing that fails on every call, and one that fails only at the final check before publishing; neither publishes.

@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Dec 5, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: MERGE at 391550d

Checked: The release helper now checks the listing exit status in the main shell before consuming inventory at prune, upload and publish. I replayed the previous 30-entry page followed by a terminal HTTP 503 at both the initial listing and the final pre-publish listing. The helper returned 1 and left the release as a draft in both cases. Initial failure also left the stray asset untouched.

Checked: All 19 existing paced-release and retry tests passed, including draft admission, stale and starter asset replacement, expected-name matching, published-tag refusal and both inventory failure cases. No live release was created.

@github-actions github-actions Bot removed changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 5, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Adversarial Core Review at bf69f4223e3f — BLOCKERS (do not merge)

The concurrency guard (repository-publication), GH_TOKEN env hygiene, and digest-based resume design are good, but four concrete bugs in scripts/gh-release-paced and scripts/gh-retry can corrupt or abort a paced snapshot publish:

  1. Unchecked < <(remote) process substitution + non-unique asset count (scripts/gh-release-paced:29-32, 35, 44-50; scripts/gh-retry:21-22):

    • set -euo pipefail does not propagate non-zero exits from < <(remote), and gh-retry prints partial $out before exiting on final failure. If pages 1..K return valid digests and page K+1 fails with 403/5xx, :29-32 silently skips pruning stray assets on later pages, and :44-50 can still satisfy n == ${#files[@]} and bad == 0 and publish with stray assets attached (confirming aurora-silicon-review).
    • :45-49 also only increments n, not unique matched names, so offset-pagination drift returning a duplicate asset while omitting another still passes n == ${#files[@]}.
    • Fix: capture inv=$(remote) (or temp file) so set -e fails immediately on any pagination error; in the final verify track seen[$name]=1, reject duplicates, and assert both n == ${#files[@]} and ${#seen[@]} == ${#want[@]}.
  2. Swallowing all release view errors (2>/dev/null || true) can create duplicate draft releases and bypass the plan-step guard (scripts/gh-release-paced:15-20, .github/workflows/publish.yml:131-136):

    • Both sites treat every non-zero exit (including 403 rate-limit exhaustion, 5xx after 5 retries, auth/network errors) as "release absent". In gh-release-paced:15-20, a transient/403 error on an existing draft falls into *) and runs gh release create --draft, creating a duplicate draft release for the same tag_name and stranding an orphan draft; in publish.yml:131-136, a failed release view on an already-published tag silently passes plan.
    • Fix: inspect stderr/status and treat only "release not found" / HTTP 404 as absent; fail loudly on any other error.
  3. gh-retry breaks when retrying 0-file gh release create (scripts/gh-release-paced:19 x scripts/gh-retry:30-41):

    • gh-release-paced:19 calls gh-retry release create "$tag" "${repo[@]}" --draft ... with zero file args. If GitHub creates the draft and the response hits a transient 5xx/timeout, gh-retry:32-39 builds files=(), sees gh release view "$tag" succeed, and rewrites the retry to gh release upload "$tag" --repo ... --clobber with no files -> gh immediately fails with requires at least 2 arg(s), only received 1 (RC=1, non-transient abort).
    • Fix: in gh-retry:37-40, when ((${#files[@]} == 0)) and the release already exists after a failed release create, return 0 instead of invoking 0-file release upload.
  4. Unchecked mapfile < <(cd "$dir" && ls -1) / empty $dir / normalized-name collisions (scripts/gh-release-paced:24-28):

    • Process substitution hides a missing/unreadable $dir failure -> files=(), :29-32 deletes every asset on any resumed draft, :49 sees 0 == 0, and :51 publishes a 0-asset release. Normalized-name collisions silently overwrite want[$g] until failing after all uploads.
    • Fix: assert [[ -d $dir ]], enumerate regular files directly without process substitution, reject ${#files[@]} == 0, and fail up front on duplicate normalized g keys.

Non-blocking hardening (worth fixing in the same pass):

  • remote() omits ?per_page=100 (defaults to 30 -> ~18 pages for 514 assets) and runs on every batch iteration (~270 extra GETs right when avoiding rate limits!). Use ?per_page=100 and populate ok once before the loop (re-listing only on batch recovery + final verify).
  • Pass --title "$title" --notes "$notes" --prerelease on gh release edit --draft=false (:51) so resumed drafts cannot publish with stale metadata.
  • Re-run pr-text after pushing (failed on installation 403 rate limit).

@RyanTheTide
RyanTheTide merged commit 1dd1cc9 into main Dec 5, 2026
40 of 42 checks passed
@RyanTheTide
RyanTheTide deleted the publish-paced-upload branch December 5, 2026 23:46
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Re-checked at 391550d81b48: capturing remote() in the main shell (scripts/gh-release-paced:24-29) resolves the unchecked < <(remote) process-substitution exit bug cleanly. The remaining items from the review above still apply at 391550d81b48:

  • Track unique asset names (seen[$name]=1) in the final check (:52-60) rather than raw line count n.
  • Inspect release view errors (scripts/gh-release-paced:15-20, .github/workflows/publish.yml:131-136) so 403/5xx does not create a duplicate draft or bypass plan.
  • Guard ((${#files[@]} == 0)) in scripts/gh-retry:37-40 so a retried 0-file release create does not invoke invalid 0-file release upload.
  • Validate $dir, non-empty files, and duplicate normalized g keys without < <(...) (:30-34).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

door:two-way Revertible or not, from Merge risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant