{"record":{"id":"598a07e5b0c7d82f","repo":"santifer/career-ops","slug":"changedsections-must-be-an-array","errorCode":null,"errorMessage":"changedSections must be an array","messagePattern":"changedSections must be an array","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"application-artifacts.mjs","lineNumber":87,"sourceCode":"    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\nfunction usage() {\n  return 'Usage: node application-artifacts.mjs --report N --company NAME --role ROLE [--version N] [--root output] [--init]';","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/santifer/career-ops/blob/60398d6549a46f5266929538af21cfab94badc75/application-artifacts.mjs#L69-L105","documentation":"Thrown by writeReuseDecision() when changedSections is not an Array. The field records which CV sections changed (serialized as changed_sections in the JSON record); a bare Array.isArray check guards it because strings are the common accidental shape.","triggerScenarios":"changedSections: 'summary, skills' (comma-separated string), changedSections: 'summary', or an object keyed by section name. The parameter defaults to [] so the throw always comes from an explicitly passed non-array.","commonSituations":"Passing a human-readable list as one string; a caller upstream joining an array with ', ' for logging and reusing the joined value; config-driven call sites reading the field from YAML/JSON that holds a string.","solutions":["Pass a real array: changedSections: ['summary', 'skills']","If the value arrives as a string, split it first: typeof s === 'string' ? s.split(',').map(x => x.trim()).filter(Boolean) : s","When nothing changed, omit the field entirely — the default [] is valid"],"exampleFix":"// before\nwriteReuseDecision(paths, { decision: 'reuse', changedSections: 'summary, skills' });\n\n// after\nwriteReuseDecision(paths, { decision: 'reuse', changedSections: ['summary', 'skills'] });","handlingStrategy":"type-guard","validationCode":"if (changedSections !== undefined && !Array.isArray(changedSections)) {\n  throw new TypeError('changedSections must be an array of section names');\n}","typeGuard":"function isSectionList(v) {\n  return v === undefined || (Array.isArray(v) && v.every((s) => typeof s === 'string'));\n}","tryCatchPattern":null,"preventionTips":["Never reuse a ', '-joined string that was built for logging as the changedSections value","Omit the field when nothing changed — the [] default is valid"],"tags":["argument-validation","type-mismatch","application-artifacts"],"backgroundTag":"invalid-argument-value","analyzedSha":"60398d6549a46f5266929538af21cfab94badc75","analyzedAt":"2026-08-20T23:00:06.764Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}