{"record":{"id":"148adf941e3b69a2","repo":"affaan-m/ECC","slug":"spec-schedule-must-be-an-array-of-six-cell-rows","errorCode":null,"errorMessage":"spec.schedule must be an array of six-cell rows","messagePattern":"spec\\.schedule must be an array of six-cell rows","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"skills/master-agreement-generator/scripts/build-agreement.js","lineNumber":60,"sourceCode":"  return now.toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' });\n}\n\nfunction encodeScheduleCell(cell) {\n  const entity = character => `&#${character.codePointAt(0)};`;\n  // Entities keep data out of Markdown/HTML syntax, including smart punctuation.\n  // Preserve single internal spaces and ordinary dates/example text as written.\n  return String(cell).replace(/\\r\\n|\\r|\\n/g, ' ')\n    .replace(/[\\\\|`*_{}[\\]<>!&#~^$'\"@]/g, entity)\n    .replace(/-{2,}|\\.{3,}/g, run => [...run].map(entity).join(''))\n    .replace(/^ +| +$| {2,}|[^\\S ]/gu, run => [...run].map(entity).join(''));\n}\n\nfunction renderScheduleRows(rows) {\n  if (rows === undefined) {\n    return EMPTY_SCHEDULE_ROW;\n  }\n  if (!Array.isArray(rows)) {\n    throw new Error('spec.schedule must be an array of six-cell rows');\n  }\n  if (rows.length === 0) return EMPTY_SCHEDULE_ROW;\n  return Array.from(rows, (row, rowIndex) => {\n    if (!Object.hasOwn(rows, rowIndex) || !Array.isArray(row) || row.length !== 6) {\n      throw new Error(`spec.schedule[${rowIndex}] must be a dense six-cell array`);\n    }\n    const cells = Array.from(row, (cell, cellIndex) => {\n      if (!Object.hasOwn(row, cellIndex) ||\n          !((typeof cell === 'string' && !/\\p{Surrogate}/u.test(cell)) ||\n            (typeof cell === 'number' && Number.isFinite(cell)))) {\n        throw new Error(`spec.schedule[${rowIndex}][${cellIndex}] must be valid Unicode text or a finite number`);\n      }\n      return encodeScheduleCell(cell);\n    });\n    return `| ${cells.join(' | ')} |`;\n  }).join('\\n');\n}\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/master-agreement-generator/scripts/build-agreement.js#L42-L78","documentation":"renderScheduleRows renders spec.schedule into a markdown table row set. If spec.schedule is present but not an array, the builder rejects it immediately. The library distinguishes 'undefined' (renders a default empty schedule row) from a wrongly-typed value, which is treated as a specification error.","triggerScenarios":"Calling buildValues/build-agreement with a spec where schedule is a non-array value — e.g. a string 'monday', an object { rows: [...] }, a Map, or JSON where schedule was meant to be an array of arrays.","commonSituations":"Hand-written YAML/JSON spec where the schedule was written as an object or string; a loader that collapsed the array; copy-pasting a single row (object) instead of an array of rows; schema drift after editing the spec generator.","solutions":["Change spec.schedule to an array of rows, each row itself an array of exactly six cells.","If the intent is no schedule, omit the field entirely (undefined) rather than passing a wrong type.","Validate the spec with Array.isArray(spec.schedule) before building.","Check the spec file's syntax: a missing dash/bracket in YAML can turn an array into a scalar or mapping."],"exampleFix":"// before\nconst spec = { schedule: { monday: ['09:00', ...] } };\n// after\nconst spec = { schedule: [['monday', '09:00', '17:00', 'break', '60', 'note']] }; // array of six-cell rows","handlingStrategy":"validation","validationCode":"function assertScheduleArray(spec) {\n  if (spec.schedule !== undefined && !Array.isArray(spec.schedule)) {\n    throw new TypeError('spec.schedule must be an array of six-cell rows (or omitted)');\n  }\n}","typeGuard":"const isSchedule = (s) => s === undefined || (Array.isArray(s) && s.every(Array.isArray));","tryCatchPattern":"try {\n  buildAgreement(spec);\n} catch (e) {\n  if (e.message.includes('spec.schedule must be an array')) {\n    spec = { ...spec, schedule: normalizeSchedule(spec.schedule) };\n    return buildAgreement(spec);\n  }\n  throw e;\n}","preventionTips":["Validate spec files with a JSON/YAML schema requiring schedule: array of arrays.","In YAML specs, double-check indentation — a lost dash turns an array into a mapping.","Omit the field entirely for 'no schedule' instead of passing a placeholder object or string."],"tags":["validation","schema","type-mismatch","spec"],"backgroundTag":"schema-validation-failed","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}