Skip to content

Commit f28c5bc

Browse files
igorcostaAutohand Evolve
andcommitted
Surface unset R2 secrets clearly in the model catalog publish script
The publish-model-catalog workflow was failing with the opaque "Invalid argument near --bucket" because the R2_MODELS_ACCESS_KEY_ID, R2_MODELS_SECRET_ACCESS_KEY, R2_ACCOUNT_ID, and R2_MODELS_BUCKET secrets are not yet configured on this repository, so every flag value resolved to an empty string. parseArgs now distinguishes a malformed flag from an empty value and names the offending flag so the real cause (an unset secret/environment variable) is obvious from the job log. Also renamed the "Generate Pi-compatible catalog" step to "Generate model catalog" to match the workflow's own name. Co-authored-by: Autohand Evolve <code-noreply@autohand.ai>
1 parent c47a0f7 commit f28c5bc

3 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎.github/scripts/publish-model-catalog.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ function parseArgs(args) {
1111
for (let index = 0; index < args.length; index += 2) {
1212
const flag = args[index];
1313
const value = args[index + 1];
14-
if (!flag?.startsWith("--") || !value) throw new Error(`Invalid argument near ${flag ?? "end of input"}`);
14+
if (!flag?.startsWith("--")) throw new Error(`Expected a flag starting with "--", found "${flag ?? "end of input"}"`);
15+
if (!value) throw new Error(`Value for ${flag} is empty or unset — check the corresponding environment variable/secret`);
1516
options[flag.slice(2)] = value;
1617
}
1718
for (const required of ["input", "bucket", "endpoint", "source-commit", "revision-prefix", "latest-key", "metadata-key"]) {

‎.github/workflows/publish-model-catalog.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
with:
2828
ref: main
2929

30-
- name: Generate Pi-compatible catalog
30+
- name: Generate model catalog
3131
run: |
3232
mkdir -p "$RUNNER_TEMP/autohand-model-catalog"
3333
node .github/scripts/generate-model-catalog.mjs \

‎tests/github/modelCatalogDistributionWorkflow.test.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,28 @@ describe("model catalog distribution automation", () => {
9090
expect(source).toContain('`revision=${revision}`');
9191
});
9292

93+
it("reports a clear error when a required flag's value is empty, e.g. an unset GitHub secret", () => {
94+
let error: (Error & { stderr?: string }) | undefined;
95+
try {
96+
execFileSync(process.execPath, [
97+
PUBLISH_SCRIPT,
98+
"--input", "/nonexistent/models.json",
99+
"--bucket", "",
100+
"--endpoint", "https://example.r2.cloudflarestorage.com",
101+
"--source-commit", "abc123",
102+
"--revision-prefix", "cli/revisions/",
103+
"--latest-key", "cli/models.json",
104+
"--metadata-key", "cli/catalog.json",
105+
], { encoding: "utf8" });
106+
} catch (caught) {
107+
error = caught as Error & { stderr?: string };
108+
}
109+
110+
expect(error).toBeDefined();
111+
expect(String(error?.stderr)).toContain("--bucket");
112+
expect(String(error?.stderr)).toContain("empty or unset");
113+
});
114+
93115
it("turns an R2 admin draft into a reviewable pull request without auto-merging", () => {
94116
const source = readFileSync(ADMIN_WORKFLOW, "utf8");
95117
const workflow = parseYaml(source) as {

0 commit comments

Comments
 (0)