Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix: pre-landing review fixes (both artifact-download clients carry the HTTP status and response text, so #8370's classification holds on the gh CLI client and a rate-limit 403 stays transient)

garrytan84ee68b61822
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c42a47e339..d69ea279cf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,7 +26,7 @@ identifiers and attribution are available in the pre-removal Git revision
### Itemized changes
-- `scripts/lib/gh-issue.ts`: `fetchArtifactJson` marks a failed artifact read transient only for no response, a 5xx, a 429 or a 403 whose message names a rate limit (#8370).
+- `scripts/lib/gh-issue.ts`: `fetchArtifactJson` marks a failed artifact read transient only for no response, a 5xx, a 429 or a 403 whose message names a rate limit (#8370). Both clients' artifact downloads now carry the HTTP status and the response text, so the `gh` CLI client (used when no `GH_TOKEN` is set) classifies the same way, and a rate-limit 403 on the zip stays transient.
- `test/scripts/ci-reuse.test.ts`: a probe checks that 403, 404 and 410 are refusals and that 429, a rate-limit 403, a 502 and no response stay transient, and that a refused receipt ends the gate's wait at once. It fails without the fix.
- `.gstack/pregate.json`: `scripts/bench/**`, `docs/eval/system-one/runners/**` and `docs/eval/system-one/generators/**` declare no lane (`[]`), which applies only where no test maps the file, so the VM-setup scripts keep `test/scripts/vm-setup-usage.test.ts` (#7690).
- `scripts/postgres-arm-weights.json`: re-mined with `bun scripts/postgres-unit-arms.ts mine` from those eight runs' 98 job logs, unscaled.
diff --git a/scripts/lib/gh-issue.ts b/scripts/lib/gh-issue.ts
index e4cec6aaab..d6e38cb2c2 100644
--- a/scripts/lib/gh-issue.ts
+++ b/scripts/lib/gh-issue.ts
@@ -112,7 +112,10 @@ function tokenClient(resolve: (path: string) => string, token: string): GitHubCl
const res = await fetch(url, { headers: { authorization: `Bearer ${token}`, accept: 'application/vnd.github+json' }, redirect: 'manual' });
const location = res.headers.get('location');
const body = location ? await fetch(location) : res;
- if (!body.ok) throw Object.assign(new Error(`GitHub download ${url} -> ${body.status}`), { status: body.status });
+ if (!body.ok) {
+ const text = await body.text().catch(() => '');
+ throw Object.assign(new Error(`GitHub download ${url} -> ${body.status}: ${text.slice(0, 300)}`), { status: body.status });
+ }
return new Uint8Array(await body.arrayBuffer());
},
};
@@ -133,7 +136,11 @@ function ghCliClient(resolve: (path: string) => string): GitHubClient {
},
async download(path: string): Promise<Uint8Array> {
const r = Bun.spawnSync(['gh', 'api', resolve(path)], { stdout: 'pipe', stderr: 'pipe' });
- if (r.exitCode !== 0) throw new Error(`gh api ${resolve(path)} failed: ${r.stderr.toString().slice(0, 300)}. Fix: gh auth login, or export GH_TOKEN.`);
+ if (r.exitCode !== 0) {
+ const err = r.stderr.toString();
+ const status = Number(/HTTP (\d{3})/.exec(err)?.[1]) || undefined;
+ throw Object.assign(new Error(`gh api ${resolve(path)} failed: ${err.slice(0, 300)}. Fix: gh auth login, or export GH_TOKEN.`), { status });
+ }
return new Uint8Array(r.stdout);
},
};
diff --git a/test/scripts/ci-reuse.test.ts b/test/scripts/ci-reuse.test.ts
index c8d397b6f6..5d742c0645 100644
--- a/test/scripts/ci-reuse.test.ts
+++ b/test/scripts/ci-reuse.test.ts
@@ -459,6 +459,31 @@ describe('ci-reuse remote-gate decision', () => {
expect(g.lines.some(l => l.includes('waiting for'))).toBe(false);
});
+ test('#8370: both real clients classify a failed artifact download the same way: 403/410 refuse, a rate-limit 403 waits', async () => {
+ const r600 = run('test.yml');
+ const listing = JSON.stringify({ artifacts: [{ id: 7, name: 'executed-identities', expired: false }] });
+ const zipFails = (code: number, text: string) => {
+ const real = globalThis.fetch;
+ globalThis.fetch = (async (url: string) => String(url).endsWith('/zip') ? new Response(text, { status: code }) : new Response(listing, { status: 200 })) as typeof fetch;
+ return gateDeps(restClient(REPO, 'token-example', async () => {})).executed(r600).finally(() => { globalThis.fetch = real; });
+ };
+ const bin = mkdtempSync(join(tmpdir(), 'ci-reuse-gh-'));
+ const ghFails = async (code: number, text: string) => {
+ writeFileSync(join(bin, 'gh'), `#!/usr/bin/env bash\ncase "$*" in *"/zip"*) echo "gh: ${text} (HTTP ${code})" >&2; exit 1;; esac\necho '${listing}'\n`, { mode: 0o755 });
+ const path = process.env.PATH;
+ process.env.PATH = `${bin}:${path}`;
+ try { return await gateDeps(restClient(REPO, '', async () => {})).executed(r600); } finally { process.env.PATH = path; }
+ };
+ try {
+ for (const fails of [zipFails, ghFails]) {
+ for (const code of [403, 404, 410]) expect(await fails(code, 'Not Found')).not.toHaveProperty('transient');
+ expect(await fails(403, 'API rate limit exceeded for installation ID 1')).toMatchObject({ transient: true });
+ expect(await fails(429, 'Too Many Requests')).toMatchObject({ transient: true });
+ expect(await fails(502, 'Bad Gateway')).toMatchObject({ transient: true });
+ }
+ } finally { rmSync(bin, { recursive: true, force: true }); }
+ });
+
/** A run's receipts as scripts/lib/test-env.sh writes them: one artifact directory per job, one test file each. */
function writeReceipts(dir: string, artifact: string, lane: string, attempt: number, tests: string[]) {
const at = join(dir, artifact); mkdirSync(at, { recursive: true });