{"record":{"id":"bee494b54e75b0a4","repo":"affaan-m/ECC","slug":"spec-schedule-rowindex-must-be-a-dense-six-cell-array","errorCode":null,"errorMessage":"spec.schedule[${rowIndex}] must be a dense six-cell array","messagePattern":"spec\\.schedule\\[(.+?)\\] must be a dense six-cell array","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"skills/master-agreement-generator/scripts/build-agreement.js","lineNumber":65,"sourceCode":"  // 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\nfunction buildValues(spec, now) {\n  if (!spec || typeof spec !== 'object') {\n    throw new Error('spec must be an object');\n  }\n  for (const key of ['file', 'short', 'role']) {","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/master-agreement-generator/scripts/build-agreement.js#L47-L83","documentation":"Each element of spec.schedule must be a dense array of exactly six cells. The renderer iterates rows and rejects any row that is not an array, has length !== 6, or contains sparse holes (Object.hasOwn check fails for an index). The thrown message names the offending row index.","triggerScenarios":"spec.schedule = [['a','b','c']] (three cells), spec.schedule = [row0, null], spec.schedule with a deleted index creating a hole (sparse array), or a row built with `new Array(6)` without filling all slots.","commonSituations":"Editing a spreadsheet-exported row and dropping a column; programmatically building rows with Array(6) (sparse) instead of Array.from/fill; merging rows of differing widths; optional trailing cells removed making the row short.","solutions":["Make every row exactly six cells: pad missing cells with '' or 0, and trim extras.","Build rows with Array.of(...) or a literal so all six indices are own properties (no holes).","If a cell is optional, pass an empty string rather than deleting the slot.","Pre-validate: rows.every(r => Array.isArray(r) && r.length === 6 && Object.hasOwn(r, 5))."],"exampleFix":"// before\nconst row = new Array(6); row[0] = 'monday';           // sparse row\n// after\nconst row = ['monday', '09:00', '17:00', 'lunch', 60, '']; // dense six-cell row","handlingStrategy":"validation","validationCode":"function assertDenseRows(schedule) {\n  schedule.forEach((row, i) => {\n    if (!Array.isArray(row) || row.length !== 6 || !Object.hasOwn(row, 5)) {\n      throw new TypeError(`spec.schedule[${i}] must be a dense six-cell array`);\n    }\n  });\n}","typeGuard":"const isDenseSixCellRow = (r) => Array.isArray(r) && r.length === 6 && Object.hasOwn(r, 5);","tryCatchPattern":"try {\n  buildAgreement(spec);\n} catch (e) {\n  const m = e.message.match(/spec\\.schedule\\[(\\d+)\\]/);\n  if (m) {\n    const i = Number(m[1]);\n    spec.schedule = spec.schedule.map((r, idx) =>\n      idx === i ? padOrTrimRow(r, 6) : r);\n    return buildAgreement(spec);\n  }\n  throw e;\n}","preventionTips":["Build rows with array literals or Array.of, never `new Array(6)` (creates holes).","Pad short rows with '' and trim long rows to 6 before building.","Add a unit test asserting every exported row passes isDenseSixCellRow."],"tags":["validation","array","schema","spec"],"backgroundTag":"shape-mismatch","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"}