{"record":{"id":"9a621f509c1ec2d1","repo":"oven-sh/bun","slug":"args-must-yield-an-array-of-file-count","errorCode":null,"errorMessage":"args must yield an array of {file,count}","messagePattern":"args must yield an array of (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/clippy-loop/de-unsafe.workflow.ts","lineNumber":12,"sourceCode":"export const meta = {\n  name: \"de-unsafe-pass\",\n  description: \"Convert pub unsafe fn(*mut T) → pub fn(&mut T) / NonNull<T>\",\n  phases: [\n    { title: \"Refactor\", detail: \"agent removes unsafe markers, changes ptr→ref\" },\n    { title: \"Review\", detail: \"1 adversarial reviewer\" },\n  ],\n};\n\nconst parsed = typeof args === \"string\" ? JSON.parse(args) : args;\nconst files = Array.isArray(parsed) ? parsed : parsed.files;\nif (!Array.isArray(files)) throw new Error(\"args must yield an array of {file,count}\");\n\nconst RESULT_SCHEMA = {\n  type: \"object\",\n  required: [\"status\", \"summary\", \"callerEdits\"],\n  properties: {\n    status: { type: \"string\", enum: [\"fixed\", \"skipped\", \"partial\"] },\n    summary: { type: \"string\" },\n    callerEdits: {\n      type: \"array\",\n      items: { type: \"string\" },\n      description: \"Files OUTSIDE this one that were edited (caller updates).\",\n    },\n  },\n  additionalProperties: false,\n};\n\nconst REVIEW_SCHEMA = {\n  type: \"object\",","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/scripts/clippy-loop/de-unsafe.workflow.ts#L1-L30","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nworkflow.run(\"de-unsafe-pass\", JSON.stringify({ file: \"src/foo.rs\", count: 3 }));\n\n// after\nworkflow.run(\"de-unsafe-pass\", JSON.stringify([{ file: \"src/foo.rs\", count: 3 }]));","handlingStrategy":"type-guard","validationCode":"const parsed = typeof args === \"string\" ? JSON.parse(args) : args;\nconst files = Array.isArray(parsed) ? parsed : parsed?.files;\nif (!Array.isArray(files) || files.some(f => typeof f?.file !== \"string\")) {\n  throw new Error(\"expected [{file,count}] or {files:[{file,count}]}\");\n}","typeGuard":"const isFileCountList = (v: unknown): v is { file: string; count: number }[] =>\n  Array.isArray(v) && v.every(x => typeof x?.file === \"string\" && typeof x?.count === \"number\");","tryCatchPattern":null,"preventionTips":["Centralize workflow-arg construction in one helper so shape mistakes surface once","Validate args at the boundary (before dispatch), not inside the workflow body"],"tags":["clippy","workflow","validation","arguments","json"],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}