oven-sh/bun · error
args must yield an array of {file,count}
Error message
args must yield an array of {file,count} What it means
The de-unsafe-pass workflow in scripts/clippy-loop/de-unsafe.workflow.ts expects args that are either a JSON array of {file,count} items or an object with a files array (a JSON string is parsed first). This error is thrown when neither shape yields an array, so the workflow has no file list to refactor.
Source
Thrown at scripts/clippy-loop/de-unsafe.workflow.ts:12
export const meta = {
name: "de-unsafe-pass",
description: "Convert pub unsafe fn(*mut T) → pub fn(&mut T) / NonNull<T>",
phases: [
{ title: "Refactor", detail: "agent removes unsafe markers, changes ptr→ref" },
{ title: "Review", detail: "1 adversarial reviewer" },
],
};
const parsed = typeof args === "string" ? JSON.parse(args) : args;
const files = Array.isArray(parsed) ? parsed : parsed.files;
if (!Array.isArray(files)) throw new Error("args must yield an array of {file,count}");
const RESULT_SCHEMA = {
type: "object",
required: ["status", "summary", "callerEdits"],
properties: {
status: { type: "string", enum: ["fixed", "skipped", "partial"] },
summary: { type: "string" },
callerEdits: {
type: "array",
items: { type: "string" },
description: "Files OUTSIDE this one that were edited (caller updates).",
},
},
additionalProperties: false,
};
const REVIEW_SCHEMA = {
type: "object",View on GitHub (pinned to 8c5296ac45)
Solutions
- Pass an array: [{"file":"src/foo.rs","count":3}] or an object {"files":[...]}
- Echo the args right before invoking the workflow to see the actual payload
- If a generator produces the args, fix it to emit the array form
Example fix
// before
workflow.run("de-unsafe-pass", JSON.stringify({ file: "src/foo.rs", count: 3 }));
// after
workflow.run("de-unsafe-pass", JSON.stringify([{ file: "src/foo.rs", count: 3 }])); Defensive patterns
Strategy: type-guard
Validate before calling
const parsed = typeof args === "string" ? JSON.parse(args) : args;
const files = Array.isArray(parsed) ? parsed : parsed?.files;
if (!Array.isArray(files) || files.some(f => typeof f?.file !== "string")) {
throw new Error("expected [{file,count}] or {files:[{file,count}]}");
} Type guard
const isFileCountList = (v: unknown): v is { file: string; count: number }[] =>
Array.isArray(v) && v.every(x => typeof x?.file === "string" && typeof x?.count === "number"); Prevention
- Centralize workflow-arg construction in one helper so shape mistakes surface once
- Validate args at the boundary (before dispatch), not inside the workflow body
When it happens
Trigger: Invoking the workflow with args like {"file":"x.rs"} (singular key, no files array), a bare string, an empty object, or JSON that parses to null or a number.
Common situations: Hand-writing the args JSON in a runner or orchestrator; a generator script changing its output shape (single object instead of array); passing the wrong variable entirely.
Related errors
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/9a621f509c1ec2d1.
Report an issue: GitHub.