{"record":{"id":"f32a41dcab870cc9","repo":"Hmbown/CodeWhale","slug":"pipeline-expected-an-array-of-items","errorCode":null,"errorMessage":"pipeline(): expected an array of items","messagePattern":"pipeline\\(\\): expected an array of items","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"crates/workflow-js/src/vm.rs","lineNumber":1616,"sourceCode":"      // A fan-out where nothing survived is a dead fan-out, not resilience.\n      // The default stays ergonomic (the array still resolves) but the run\n      // log says so in one line an operator can grep for, and the structured\n      // event below lets the host status classifier refuse to call such a\n      // run a plain success.\n      if (results.length > 0 && errors.length === results.length) {\n        hostLog(\n          \"parallel(): every slot failed (\" + errors.length + \" of \" + results.length +\n          \"); no work survived this fan-out\"\n        );\n        hostEverySlotFailed(\"parallel\", errors.length, results.length);\n      }\n      return attachSlotErrors(results, errors);\n    });\n  };\n\n  globalThis.pipeline = (items, ...stages) => {\n    if (!Array.isArray(items)) {\n      throw new TypeError(\"pipeline(): expected an array of items\");\n    }\n    if (items.length > MAX_ITEMS) {\n      throw new Error(\"pipeline(): max \" + MAX_ITEMS + \" items per call\");\n    }\n    // Options overload: pipeline(items, { stages: [...], mode: \"fail-fast\" }).\n    let mode = \"settled\";\n    if (\n      stages.length === 1 &&\n      stages[0] !== null &&\n      typeof stages[0] === \"object\" &&\n      Array.isArray(stages[0].stages)\n    ) {\n      mode = slotMode(\"pipeline\", stages[0]);\n      stages = stages[0].stages;\n    }\n    const failFast = mode === \"fail-fast\";\n    const partial = mode === \"partial\";\n    const errors = [];","sourceCodeStart":1598,"sourceCodeEnd":1634,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/workflow-js/src/vm.rs#L1598-L1634","documentation":"Thrown by the prelude's `globalThis.pipeline` in vm.rs when its first argument is not an array. `pipeline(items, ...stages)` feeds an array of items through stage functions, so a non-array first argument is rejected with this TypeError before any stage runs.","triggerScenarios":"Calling `pipeline(item)` with a single item instead of `[item]`; passing an object, string, or non-array iterable as items; argument order mistakes when using the options overload `pipeline(items, { stages: [...], mode })`.","commonSituations":"Forgetting to wrap a lone item in an array; passing a Map/Set or generator result directly; refactoring from parallel() to pipeline() with mismatched argument shapes.","solutions":["Wrap single values in an array: `pipeline([item], stage)`.","Convert non-array iterables: `pipeline(Array.from(items), ...stages)`.","Confirm the first argument is the items array and stages follow as extra arguments.","Pass `[]` for an empty pipeline run instead of null/undefined."],"exampleFix":"// before\nconst out = await pipeline(order, normalize, enrich);\n// after\nconst out = await pipeline([order], normalize, enrich);","handlingStrategy":"type-guard","validationCode":"function assertItems(items) {\n  if (!Array.isArray(items)) {\n    throw new TypeError('pipeline() requires an array of items; wrap a single item in [item]');\n  }\n}","typeGuard":"function isItemArray(v) {\n  return Array.isArray(v);\n}","tryCatchPattern":"try {\n  const out = await pipeline(items, ...stages);\n} catch (e) {\n  if (e instanceof TypeError && e.message === 'pipeline(): expected an array of items') {\n    console.error('pipeline([items...], ...stages) — first argument must be an array');\n  } else throw e;\n}","preventionTips":["Wrap single values in an array before pipelining.","Convert iterables with Array.from first.","Keep (items, ...stages) argument order; options overload is pipeline(items, { stages, mode }).","When migrating from parallel(), check argument shapes match."],"tags":["workflow","argument-validation","typeerror"],"backgroundTag":"type-mismatch","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}