{"record":{"id":"dbe5d326aa9a3d44","repo":"santifer/career-ops","slug":"decision-must-be-one-of-decisions-join","errorCode":null,"errorMessage":"decision must be one of: ${[...DECISIONS].join(', ')}","messagePattern":"decision must be one of: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"application-artifacts.mjs","lineNumber":87,"sourceCode":"    join(paths.root, 'jd'),\n    join(paths.root, 'cv', 'source'),\n    paths.cv.tailored.root,\n    join(paths.root, 'decision'),\n  ]) mkdirSync(directory, { recursive: true });\n  return paths;\n}\n\n/** Write an auditable CV reuse decision beside the application artifacts. */\nexport function writeReuseDecision(paths, {\n  decision,\n  score = null,\n  sourceCv = null,\n  currentJd = null,\n  previousSource = null,\n  changedSections = [],\n  userOverride = false,\n}) {\n  if (!DECISIONS.has(decision)) throw new Error(`decision must be one of: ${[...DECISIONS].join(', ')}`);\n  if (!Array.isArray(changedSections)) throw new Error('changedSections must be an array');\n  ensureApplicationArtifactDirs(paths);\n  const record = {\n    schema_version: 1,\n    decision,\n    score,\n    source_cv: sourceCv,\n    current_jd: currentJd,\n    previous_source: previousSource,\n    changed_sections: changedSections,\n    user_override: Boolean(userOverride),\n    recorded_at: new Date().toISOString(),\n  };\n  writeFileSync(paths.decision.reuse, `${JSON.stringify(record, null, 2)}\\n`);\n  return record;\n}\n\n// --help was swallowed by parseArgs's strict mode and reported as an unknown","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/application-artifacts.mjs#L69-L105","documentation":"writeReuseDecision persists a CV-reuse decision record and validates the decision against the DECISIONS enum set before writing. If decision is not one of the enumerated values, it throws listing the allowed values. This prevents invalid decision labels from being archived into the application artifact bundle.","triggerScenarios":"Calling writeReuseDecision with decision set to a misspelled or differently-cased value (e.g. 'Reuse', 'reuse_full', 'FULL_REUSE'), an empty string, null/undefined, or a raw value read from user input or an older schema version that predates the current enum.","commonSituations":"Refactoring renamed an enum member but a call site (or persisted JSON being replayed) still uses the old label; a UI dropdown sends free text; a script passes a CLI string directly without mapping it to the enum; comparing against a similarly named but distinct constant imported from the wrong module.","solutions":["Read the exact allowed values from the thrown message (the DECISIONS set) and pass one verbatim, matching case and spelling.","Import the decision constants from the module instead of hand-writing string literals, so renames are caught by the linter/runtime.","If the value comes from persisted data or an older record, map/normalize it to the current enum before calling (with a fallback for unknown legacy labels).","Log or inspect the actual value with typeof/value when unsure — undefined means the property name was mistyped in the call."],"exampleFix":"// before\nawait writeReuseDecision({ paths, decision: 'full-reuse', score: 4.5 });\n// after\nimport { DECISIONS } from './application-artifacts.mjs';\nif (!DECISIONS.has('full-reuse')) throw new Error('unknown decision: full-reuse');\nawait writeReuseDecision({ paths, decision: DECISION_FULL_REUSE, score: 4.5 }); // use exported constant","handlingStrategy":"validation","validationCode":"import { DECISIONS } from './application-artifacts.mjs';\nif (!DECISIONS.has(decision)) {\n  throw new Error(`decision '${decision}' not in: ${[...DECISIONS].join(', ')}`);\n}","typeGuard":"const isDecision = (d) => DECISIONS.has(d);","tryCatchPattern":"try {\n  await writeReuseDecision({ paths, decision, score });\n} catch (err) {\n  if (err.message.startsWith('decision must be one of')) {\n    console.error(`Unknown decision '${decision}'. Allowed: ${err.message.match(/one of: (.*)$/)?.[1]}`);\n  } else throw err;\n}","preventionTips":["Use the exported decision constants instead of raw string literals.","Copy the exact enum values from the error message — they are listed verbatim.","Normalize case/whitespace on values sourced from UIs or files before calling.","When replaying persisted records, map legacy labels to the current enum first."],"tags":["validation","enum","arguments"],"backgroundTag":"invalid-enum-value","analyzedSha":"aac998c7ed7248ea853b720ceeb1fdbeb322fc5d","analyzedAt":"2026-09-16T06:35:29.214Z","contentChangedAt":"2026-09-16T06:35:29.214Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}