Avoid stale GitHub release asset redirects (#65127)

## Why

GitHub release asset URLs can return cached redirects whose signatures
have expired, causing dependency downloads to fail during CI setup and
packaging.

## What changed

Add a fresh `cache_bust` query parameter to rusty-v8 artifact downloads in
CI and packaging, the Windows voice setup's `pkgconf` MSI download, and
DotSlash archive downloads that use plain GitHub release asset URLs.

GitOrigin-RevId: 560bfdb5788032f6450920b986cd30363eda996e
This commit is contained in:
Ian MacLeod authored and copyberry committed 2026-12-02 01:08:01 +00:00
1 parent 4487f68480
commit 0cc4569555
4 files changed
+20 -6

No files matched your search

+5 -3
View File
@@ -41,8 +41,10 @@ runs:
checksum_command=(shasum -a 256 --check -)
fi
# A fresh query avoids cached GitHub redirects with expired signatures.
query="cache_bust=$(date +%s)"
mkdir -p "${binding_dir}"
curl -fsSL "${base_url}/${checksums_name}" -o "${checksums_path}"
curl -fsSL "${base_url}/${checksums_name}?${query}" -o "${checksums_path}"
# Check the original manifest bytes even when either checksum file uses CRLF.
expected_manifest_checksum="$(grep -F " ${checksums_name}" "${trusted_checksums}" | cut -d ' ' -f 1)"
actual_manifest_checksum="$(python3 -c 'import hashlib, pathlib, sys; print(hashlib.sha256(pathlib.Path(sys.argv[1]).read_bytes()).hexdigest())' "${checksums_path}")"
@@ -50,8 +52,8 @@ runs:
echo "Checksum mismatch for ${checksums_name}: expected ${expected_manifest_checksum}, got ${actual_manifest_checksum}" >&2
exit 1
fi
curl -fsSL "${base_url}/${archive_name}" -o "${archive_path}"
curl -fsSL "${base_url}/${binding_name}" -o "${binding_path}"
curl -fsSL "${base_url}/${archive_name}?${query}" -o "${archive_path}"
curl -fsSL "${base_url}/${binding_name}?${query}" -o "${binding_path}"
if [[ "$(wc -l < "${checksums_path}")" -ne 2 ]]; then
echo "Expected exactly two checksums for ${TARGET} in ${checksums_path}" >&2
+2 -1
View File
@@ -32,7 +32,8 @@ $Inputs = @(
digest = "6acea47c59781c9e7f544a18d53935d59df6e44d5d52ac95ee165671b8e388820455eebf30ccc7d254b00c3d0eb694269a0f8dc84b17944c1f355dac9c5aafcc"
},
@{
url = "https://github.com/pkgconf/pkgconf/releases/download/pkgconf-3.0.6/pkgconf-$($PkgHashes[$Target][0])-3.0.6.msi"
# A fresh query avoids cached GitHub redirects with expired signatures.
url = "https://github.com/pkgconf/pkgconf/releases/download/pkgconf-3.0.6/pkgconf-$($PkgHashes[$Target][0])-3.0.6.msi?cache_bust=$([guid]::NewGuid())"
file = "pkgconf.msi"
algorithm = "SHA256"
digest = $PkgHashes[$Target][1]
+8
View File
@@ -3,10 +3,12 @@
import gzip
import hashlib
import json
import re
import shutil
import stat
import tarfile
import tempfile
import time
import zipfile
from dataclasses import dataclass
from pathlib import Path
@@ -168,6 +170,12 @@ def download_archive(url: str, archive_path: Path) -> None:
temp_path = archive_path.with_suffix(f"{archive_path.suffix}.tmp")
temp_path.unlink(missing_ok=True)
try:
# A fresh query avoids cached GitHub redirects with expired signatures.
if re.fullmatch(
r"https://github\.com/[^/?#]+/[^/?#]+/releases/download/[^/?#]+/[^/?#]+",
url,
):
url = f"{url}?cache_bust={time.time_ns()}"
request = Request(url, headers={"User-Agent": "codex-package"})
with urlopen(request, timeout=DOWNLOAD_TIMEOUT_SECS) as response:
with open(temp_path, "wb") as out:
+5 -2
View File
@@ -6,6 +6,7 @@ import hashlib
import os
import shutil
import tempfile
import time
from collections.abc import Mapping
from dataclasses import dataclass
from pathlib import Path
@@ -59,6 +60,8 @@ def fetch_codex_v8_artifacts(
release_url = (
f"https://github.com/openai/codex/releases/download/rusty-v8-v{version}"
)
# A fresh query avoids cached GitHub redirects with expired signatures.
query = f"cache_bust={time.time_ns()}"
target = spec.target
cache_dir = (cache_root or default_cache_root()) / f"rusty-v8-{version}-{target}"
@@ -85,14 +88,14 @@ def fetch_codex_v8_artifacts(
except (OSError, RuntimeError, ValueError):
pass
if not cached_manifest_valid:
download_file(f"{release_url}/{checksums.name}", checksums)
download_file(f"{release_url}/{checksums.name}?{query}", checksums)
verify_release_checksum_manifest(checksums, version=version)
expected_checksums = load_checksums(checksums, {archive.name, binding.name})
for artifact in [archive, binding]:
ensure_valid_artifact(
artifact,
expected_checksums[artifact.name],
f"{release_url}/{artifact.name}",
f"{release_url}/{artifact.name}?{query}",
)
return RustyV8ArtifactPair(archive=archive, binding=binding)