{"record":{"id":"f139953b56300c78","repo":"Hmbown/CodeWhale","slug":"fn-unknown-mode-json-stringify-opts-mode-expected-one-of-vm","errorCode":null,"errorMessage":"${fn}(): unknown mode ${JSON.stringify(opts.mode)}; expected one of ${SLOT_MODES.join(\", \")}","messagePattern":"(.+?)\\(\\): unknown mode (.+?); expected one of (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/workflow-js/src/vm.rs","lineNumber":1500,"sourceCode":"      } catch (_) {\n        // A frozen error keeps whatever it has; the log line still names it.\n      }\n    }\n    return err;\n  };\n\n  const SLOT_MODES = [\"settled\", \"fail-fast\", \"partial\"];\n  // `settled` is the default and is exactly today's behavior: a non-fatal\n  // slot failure resolves to `null` so an author need not handle every error.\n  // An unrecognized mode throws rather than silently falling back — a typo\n  // like `mode: \"failfast\"` used to read as `settled` and quietly keep\n  // dropping slots the author believed were now fatal.\n  const slotMode = (fn, opts) => {\n    if (opts === null || typeof opts !== \"object\" || opts.mode === undefined) {\n      return \"settled\";\n    }\n    if (SLOT_MODES.indexOf(opts.mode) === -1) {\n      throw new Error(\n        fn + \"(): unknown mode \" + JSON.stringify(opts.mode) +\n        \"; expected one of \" + SLOT_MODES.join(\", \")\n      );\n    }\n    return opts.mode;\n  };\n\n  // The failure ledger for one fan-out, attached to the resolved array as a\n  // non-enumerable `errors` property. Non-enumerable and non-index, so the\n  // array's contents, length, and JSON encoding are byte-identical to before:\n  // `results.filter(Boolean)` still works, and a script that wants to know\n  // WHY a slot is null can now ask instead of guessing.\n  const attachSlotErrors = (results, errors) => {\n    errors.sort((a, b) => a.index - b.index);\n    Object.defineProperty(results, \"errors\", {\n      value: Object.freeze(errors.map((entry) => Object.freeze(entry))),\n      enumerable: false,\n      configurable: false,","sourceCodeStart":1482,"sourceCodeEnd":1518,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/workflow-js/src/vm.rs#L1482-L1518","documentation":"Thrown by the prelude's `slotMode` helper in vm.rs when `task()`/`parallel()`/`pipeline()` receive an `opts.mode` value that is not one of the allowed SLOT_MODES (e.g. \"settled\", \"fail-fast\", \"partial\"). This fail-loud validation prevents typos like \"failfast\" from silently falling back to default behavior and dropping slots the author believed were fatal.","triggerScenarios":"Calling `parallel(thunks, { mode: \"failfast\" })`, `pipeline(items, { stages: [...], mode: \"Fail-Fast\" })`, or any opts object whose `mode` is a misspelled/case-wrong/unsupported string; also passing mode as a non-string (e.g. true or 1).","commonSituations":"Typo or wrong casing in the mode literal; inventing a mode name that does not exist; copying an option from another library's fan-out API; passing a non-string value.","solutions":["Use one of the documented SLOT_MODES exactly: check the list in the error message (joined after 'expected one of').","Fix casing/spelling — modes are exact string matches (e.g. \"fail-fast\", not \"failfast\").","Omit `mode` entirely if you want the default \"settled\" behavior (mode === undefined falls back to it).","Ensure `mode` is a string, not a boolean/number."],"exampleFix":"// before\nawait parallel(thunks, { mode: \"failfast\" });\n// after\nawait parallel(thunks, { mode: \"fail-fast\" });","handlingStrategy":"validation","validationCode":"const SLOT_MODES = [\"settled\", \"fail-fast\", \"partial\"]; // per docs/error message\nfunction assertMode(mode) {\n  if (mode !== undefined && !SLOT_MODES.includes(mode)) {\n    throw new Error(`unknown mode ${JSON.stringify(mode)}; expected one of ${SLOT_MODES.join(\", \")}`);\n  }\n}","typeGuard":"function isSlotMode(v) {\n  return v === undefined || (typeof v === 'string' && [\"settled\", \"fail-fast\", \"partial\"].includes(v));\n}","tryCatchPattern":"try {\n  await parallel(thunks, { mode });\n} catch (e) {\n  if (e.message.includes('unknown mode')) {\n    console.error(`bad mode literal ${opts.mode}; use one listed in the error`);\n  } else throw e;\n}","preventionTips":["Copy mode literals exactly as documented; watch hyphens and casing.","Omit mode (or pass undefined) when you want the default \"settled\".","Centralize mode constants instead of inline strings.","Check the error message's 'expected one of' list — it enumerates valid values."],"tags":["workflow","invalid-enum","validation"],"backgroundTag":"invalid-enum-value","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"}