Skip to content

The agent that grows with you

fix(releases): channel handoff treats the request's own commit as provenance

ethernet5aa7446aa06e
diff --git a/scripts/releases/handoff.py b/scripts/releases/handoff.py
index 3972d86aa5e..da3575bda88 100644
--- a/scripts/releases/handoff.py
+++ b/scripts/releases/handoff.py
@@ -288,7 +288,13 @@ def main(argv: list[str] | None = None) -> None:
parser.error('--public-base is only supported for fetch')
if args.channel_request:
request = json.loads(args.channel_request.read_text(encoding="utf-8-sig"))
- if args.tag or args.commit_build or (args.commit and args.commit != request.get("commit")):
+ # One-dispatch runs export HERMES_PAYLOAD_TAG/HERMES_BUILD_COMMIT to
+ # every leg, and argparse defaults pick them up even when the leg's
+ # explicit args name only --channel-request. A commit equal to the
+ # request's own is provenance, not selection; only a genuinely
+ # different commit (or any tag) is an override attempt.
+ if args.tag or (args.commit_build and args.commit_build != request.get("commit")) \
+ or (args.commit and args.commit != request.get("commit")):
parser.error("Channel requests cannot select a tag or another commit")
if args.command == "stage":
if len(args.name) != 1 or not args.include:
diff --git a/tests/ci/test_channel_build_publication.py b/tests/ci/test_channel_build_publication.py
index 59d7773061a..4c6257adebe 100644
--- a/tests/ci/test_channel_build_publication.py
+++ b/tests/ci/test_channel_build_publication.py
@@ -335,6 +335,15 @@ def test_channel_windows_record_stage_and_assembly_handoff_shell(tmp_path, r2_se
script = workflow_step("desktop-bundled-release.yml", "build-win32-commit", "Record and stage channel windows packages")
result = run_shell(tmp_path, r2_server, script, env)
assert result.returncode == 0, result.stdout + result.stderr
+ # One-dispatch: the env-default commit equals the request's own, which is
+ # provenance, not selection — the channel stage must accept it.
+ for key in ("metadata-windows-x64.json", "handoff-win32-x64.json"):
+ r2_server.store.pop(prefix + key)
+ result = run_shell(tmp_path, r2_server, script, dict(env, HERMES_BUILD_COMMIT=request["commit"]))
+ assert result.returncode == 0, result.stdout + result.stderr
+ # A different commit stays an override attempt (and stages nothing).
+ result = run_shell(tmp_path, r2_server, script, dict(env, HERMES_BUILD_COMMIT="d" * 40))
+ assert result.returncode != 0 and "another commit" in result.stderr
receipt_key = handoff.channel_prefix(request) + "handoff-win32-x64.json"
receipt = json.loads(r2_server.store[receipt_key][0])
assert receipt["request"] == request