Skip to content

Commit 40947da

Browse files
authored
fix(test-suite): fail fast on missing gh package scope (#2270)
1 parent 3ebf71a commit 40947da

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

test-suite/fhevm/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ Most users should start with `latest-main`.
6262

6363
Use `latest-supported`, network targets, or `sha` when you are reproducing a known supported or deployed bundle rather than validating current mainline behavior.
6464

65+
Live target resolution uses GitHub metadata. For `latest-main`, `sha`, and network targets, install `gh` and authenticate it with package-read access, for example `gh auth refresh -s read:packages`, or provide a `GH_TOKEN` with that scope.
66+
6567
Compat is mainly there to protect those reproduction and cross-era paths. For the common `latest-main` path, the mental model should stay simple: mainline baseline, optional surgical local or CI repo-owned overrides, explicit topology when needed. For the shim/incompatibility decision tree, see `COMPAT.md`.
6668

6769
## Quick Start

test-suite/fhevm/src/resolve.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { writeFile } from "node:fs/promises";
33
import { describe, expect, test } from "bun:test";
44

55
import { validateBundleCompatibility } from "./compat/compat";
6-
import { shouldRetryGitHubCliError, shouldStopPackageTagScan } from "./resolve/github";
6+
import { explainGitHubCliError, shouldRetryGitHubCliError, shouldStopPackageTagScan } from "./resolve/github";
77
import {
88
SIMPLE_ACL_MIN_SHA,
99
SHA_RUNTIME_COMPAT_MIN_SHA,
@@ -154,6 +154,14 @@ describe("resolve", () => {
154154
expect(shouldRetryGitHubCliError("gh: HTTP 404")).toBe(false);
155155
});
156156

157+
test("rewrites missing package scope errors into actionable guidance", () => {
158+
expect(
159+
explainGitHubCliError(
160+
"gh: You need at least read:packages scope to get a package's versions. (HTTP 403)",
161+
),
162+
).toContain("gh auth refresh -s read:packages");
163+
});
164+
157165
test("stops package tag scans when the requested tag is found", () => {
158166
expect(
159167
shouldStopPackageTagScan(

test-suite/fhevm/src/resolve/github.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ const GH_API_RETRY_DELAY_MS = 1_000;
1313
const GH_PACKAGE_VERSION_LIMIT = 5_000;
1414

1515
/** Rewrites raw `gh` failures into actionable user-facing guidance. */
16-
const explainGitHubCliError = (message: string): string => {
16+
export const explainGitHubCliError = (message: string): string => {
1717
const lower = message.toLowerCase();
1818
if (lower.includes("enoent") || lower.includes("not found")) {
1919
return "GitHub CLI `gh` is required. Install `gh`, authenticate with `gh auth login` or GH_TOKEN, or use `--lock-file` / `--target latest-supported` to avoid GitHub resolution.";
2020
}
21+
if (lower.includes("read:packages") || lower.includes("scope to get a package") || (lower.includes("http 403") && lower.includes("package"))) {
22+
return "GitHub API is missing package-read scope. Run `gh auth refresh -s read:packages`, export GH_TOKEN with `read:packages`, or use `--lock-file` / `--target latest-supported` to avoid GitHub resolution.";
23+
}
2124
if (lower.includes("401") || lower.includes("authentication")) {
2225
return "GitHub API not authenticated. Run `gh auth login`, export GH_TOKEN, or use `--lock-file` / `--target latest-supported` to avoid GitHub resolution.";
2326
}

0 commit comments

Comments
 (0)