Repository navigation
ci(release): stop a missed stable release from looking exactly like a normal merge - #195
Conversation
execute-release.yml decided whether a push to main was the promotion by matching
the head commit subject:
[[ "$MESSAGE" =~ ^chore:\ promote\ testing\ to\ main ]]
The promotion branch carries a commit with exactly that subject, so squashing the
single-commit promotion PR inherits it and the check works. A merge commit does
not:
Merge pull request #181 from projectbluefin/auto/promote-testing-to-main
and the promotion PR body recommends precisely that -- `gh pr merge --merge
--admin`. An edited squash subject misses too.
The bad part is not that it can miss. It is that missing is invisible.
check-trigger succeeds, execute is skipped, the workflow reports green, main
advances, and no :stable tag moves. That is byte-for-byte what an ordinary merge
to main looks like, so nothing distinguishes a release that was never cut from a
day with no release. Confirmed on the real thing: run 35454830793 on main reports
`Execute stable release: success` with `execute: skipped`, which is correct
there, and would look the same if a genuine promotion had silently failed to
trigger.
Two changes, both in scripts/release-trigger.py so they can be tested:
A commit that arrived from auto/promote-testing-to-main is a promotion whatever
its subject says, found by asking which pull requests contain the commit. The
lookup is fail-open to not-a-promotion: no token, a rate limit or a commit with
no PR returns an empty list rather than an error, so the worst case is the
behaviour we already had.
And every outcome annotates itself. A recognised promotion says so; one
recognised by branch rather than subject warns, and names squashing as the
remedy; a push that is not a promotion states that no :stable tag was moved and
how to cut one. A bare skipped job is the thing being fixed, so silence is not
an acceptable outcome for any path.
Only the subject line is read, so a commit body quoting the phrase cannot
trigger a release.
14 tests drive the real decision function and the real script, including the
merge-commit case, the " (#181)" suffix GitHub appends, a failed gh lookup, and
that the inline regex has not come back. 255 tests pass; check_workflow_outputs
and check-download-integrity clean.
Not fixed here: the promotion PR footer that recommends --merge lives in
projectbluefin/actions (reusable-promote-squash.yml), outside this repository.
This makes that advice harmless rather than correct.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W6BYLUD6KBzF8rBFXKjP7M
|
The job died pulling the base image, before any build logic ran: A registry transfer failure from quay.io during blob copy, exit 125 from the container runtime. This PR changes three files — I tried to re-run the failed job and the API refused with "This workflow is already running" — other jobs in the run are still in flight. I will re-run once it completes; that is the one re-run this warrants, and a second failure I will treat as real rather than as another transfer error. One note for whoever looks at the log: the string Generated by Claude Code |
|
Step "Build the kernel cache image if it is not published yet" died pulling the base image from Quay's CDN:
A re-run should clear it. I don't have — hive: agent=scanner backend=copilot model=claude-opus-5 copilot=1.0.78 |
There was a problem hiding this comment.
security
The PR-lookup trusts a fork-controlled branch name. pull_request_head_refs extracts .[].head.ref (scripts/release-trigger.py:49) from repos/{repo}/commits/{sha}/pulls and decide treats any match of auto/promote-testing-to-main as a promotion (scripts/release-trigger.py:82). head.ref is just the branch name — it is attacker-chosen for fork PRs, and the endpoint associates a merge/squash commit on main with the PR it came from. So an otherwise-innocuous fork PR whose branch happens to be named auto/promote-testing-to-main, once merged, sets is-promotion=true and runs execute (contents: write, packages: write — .github/workflows/execute-release.yml), cutting an unintended :stable release. Reviewers don't normally vet head branch names, so this crosses the fork trust boundary the subject-prefix check never did.
Fix: constrain the jq to same-repo heads, e.g. .[] | select(.head.repo.full_name == "<repo>") | .head.ref (or compare head.label against projectbluefin:auto/promote-testing-to-main), and add a test with a fork ref.
No findings from: correctness, intent-alignment, style, docs-currency.
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.78
head.ref is attacker-chosen on a fork pull request, and GitHub associates the merge or squash commit on main with the pull request it came from. A fork branch named auto/promote-testing-to-main therefore made an innocuous merge look exactly like the promotion, and the execute job cuts a :stable release with contents: write and packages: write. Ask the API for the head repository alongside the head ref and keep only refs whose head.repo.full_name is this repository, so a fork branch name is not a release trigger. The filter is in Python rather than the jq string so tests cover it: a fork branch with the promotion name, a deleted fork reporting a null repo, and the real promotion branch surviving alongside a spoofed one. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
castrojo
left a comment
There was a problem hiding this comment.
Reviewed diff and CI runs: hardens release trigger logic to prevent missed stable releases from looking like normal merges. All CI checks pass. Awaiting review from an independent maintainer to satisfy policy.
Danathar
left a comment
There was a problem hiding this comment.
Reviewed head 1adcd1c in a local clone. scripts/release-trigger.py keeps the old subject-prefix rule and workflow_dispatch rule, and adds a branch check that only counts pull request heads whose head.repo.full_name equals the repository, so a fork branch named auto/promote-testing-to-main cannot trigger a release. I ran the same gh api commits//pulls query with the PR's jq against the current tip of main and it reports the fork's full name (mrbobbytables/utah), which the filter excludes, so the trust boundary works against the real API. A failed lookup returns an empty list and the push is classified as not a promotion with a notice, which matches today's behaviour. python3 -m unittest tests.test_release_trigger passes (17 tests), the whole suite passes via tests/run_suite.py, and the check-trigger job has the checkout, GH_TOKEN and pull-requests: read permission the script needs. The branch merges cleanly with current main.
castrojo
left a comment
There was a problem hiding this comment.
Second review: verified release-trigger.py correctly gates on branch origin and informs annotations without leaking permissions.
The problem
execute-release.ymldecides whether a push tomainis the testing→main promotion by matching the head commit subject:The promotion branch carries a commit with exactly that subject, so squashing the single-commit promotion PR inherits it and the check works. A merge commit does not:
And #181's own footer recommends precisely that:
gh pr merge <pr-number> --repo projectbluefin/utah --merge --admin. An edited squash subject misses too.The bad part is not that it can miss — it is that missing is invisible.
check-triggersucceeds,executeis skipped, the workflow reports green,mainadvances, and no:stabletag moves. That is byte for byte what an ordinary merge tomainlooks like, so nothing distinguishes "the release was never cut" from "there was no release today". The only way to notice is to go and check whether the tag moved.This is observable on the real thing right now. Run 35454830793, the push of #158 to
main:Correct there — #158 is not a promotion. And identical to what a silently-failed promotion would produce.
The change
Both parts live in
scripts/release-trigger.pyso they are testable rather than inline shell.1. A commit that arrived from
auto/promote-testing-to-mainis a promotion whatever its subject says. Found by asking which pull requests contain the commit. The lookup is deliberately fail-open to not-a-promotion: a missing token, a rate limit, or a commit with no PR returns an empty list rather than an error, so the worst case is exactly the behaviour we have today — never a spurious release.2. Every outcome annotates itself. A recognised promotion says so. One recognised by branch rather than subject emits a
::warningand names squashing as the remedy, so the merge-method problem surfaces the first time it happens instead of silently. A push that is not a promotion emits a::noticestating that no:stabletag was moved and how to cut one. A bare skipped job is the thing being fixed, so silence is not an acceptable outcome on any path.Only the subject line is read, so a commit body quoting the phrase cannot trigger a release.
Old versus new on the case that motivated it:
Tests
14 tests, driving the real decision function and the real script rather than reading them as text:
" (#181)"suffix GitHub appends to squash subjectsghlookup degrades to not-a-promotion rather than crashingGITHUB_OUTPUTactually receivesis-promotion=true/falsepull-requests: readand the env it needs, and the inline regex has not come back255 tests pass.
check_workflow_outputs.pyandcheck-download-integrity.pyclean.Scope note
release-trigger.pyis CI-only and is deliberately not added to theJustfile'stest -f scripts/...list — that list covers scripts installed into the image, and this one never is.Not fixed here: the footer recommending
--mergeis generated byreusable-promote-squash.ymlinprojectbluefin/actions, outside this repository. This change makes that advice harmless rather than correct; fixing the advice itself needs a PR there.Found while answering "what's the strategy for promote to stable?" — Utah has never cut either tag (
:testingand:stableare both 404 for all four images, checked with an anonymous GHCR pull token), so this would have been a first-release trap rather than a regression.🤖 Generated with Claude Code
https://claude.ai/code/session_01W6BYLUD6KBzF8rBFXKjP7M
Generated by Claude Code