{"record":{"id":"1ef3c77f9758ccac","repo":"Hmbown/CodeWhale","slug":"fn-unknown-mode-json-stringify-opts-mode-expected-one-of","errorCode":null,"errorMessage":"fn + \"(): unknown mode \" + JSON.stringify(opts.mode) + \"; expected one of \" + SLOT_MODES.join(\", \")","messagePattern":"fn \\+ \"\\(\\): unknown mode \" \\+ JSON\\.stringify\\(opts\\.mode\\) \\+ \"; expected one of \" \\+ SLOT_MODES\\.join\\(\", \"\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/workflow-js/src/vm.rs","lineNumber":1333,"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":1315,"sourceCodeEnd":1351,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/workflow-js/src/vm.rs#L1315-L1351","documentation":"slotMode() validates the opts.mode given to parallel()/pipeline() against the allowed SLOT_MODES. An options object with a mode outside that set throws this error naming the function, the bad mode, and the valid modes. Missing mode or a non-object opts defaults to \"settled\" without error.","triggerScenarios":"Calling parallel(thunks, { mode: '...' }) or pipeline(items, { mode: '...' }) with a mode string not in SLOT_MODES (e.g. 'abort', 'failfast', 'Fail-Fast', or a non-string value like true or 1).","commonSituations":"Typos ('failfast' vs 'fail-fast'), assuming other modes exist, casing mistakes, or passing a boolean where the mode string was expected.","solutions":["Use exactly one of the listed modes; per the code paths these are 'settled', 'fail-fast', and 'partial'.","Fix casing/spelling: 'fail-fast' is hyphenated and lowercase.","Omit the mode option entirely to get the default 'settled' behavior.","Log JSON.stringify(opts.mode) at the call site to see the actual value being passed."],"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'];\nfunction validSlotMode(opts) {\n  return opts == null || typeof opts !== 'object' || opts.mode === undefined\n    || SLOT_MODES.includes(opts.mode);\n}","typeGuard":"const isSlotOpts = (o) => o == null || (typeof o === 'object' && (o.mode === undefined || ['settled','fail-fast','partial'].includes(o.mode)));","tryCatchPattern":"try {\n  await parallel(thunks, opts);\n} catch (e) {\n  if (e.message.includes('unknown mode')) {\n    await parallel(thunks); // fall back to default 'settled'\n  } else throw e;\n}","preventionTips":["Use the exact literal mode strings: 'settled', 'fail-fast', 'partial'","Omit mode when you want the default settled behavior","Centralize slot option construction in one helper"],"tags":["invalid-enum","workflow","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}