{"record":{"id":"7125c67a7a974815","repo":"jackwener/OpenCLI","slug":"manifestpath-row-index-1-must-be-an-object","errorCode":null,"errorMessage":"manifestPath row ${index + 1} must be an object","messagePattern":"manifestPath row (.+?) must be an object","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/grok/export-utils.js","lineNumber":81,"sourceCode":"        if (!GROK_CONVERSATION_ID_RE.test(id)) {\n            throw new CommandExecutionError(`${label} returned a malformed row`, `Row ${index + 1} is missing a valid Grok conversation id.`);\n        }\n        return {\n            id,\n            title: row.title == null || row.title === '' ? '' : String(row.title),\n            date: row.date == null || row.date === '' ? '' : String(row.date),\n            url: normalizeGrokUrl(row.url, id, (reason) => new CommandExecutionError(`${label} returned a malformed row`, reason)),\n        };\n    });\n}\n\nexport function normalizeManifestRows(rows) {\n    if (!Array.isArray(rows)) {\n        throw new ArgumentError('manifestPath', 'must point to a JSON array exported by grok/export');\n    }\n    return rows.map((row, index) => {\n        if (!row || typeof row !== 'object' || Array.isArray(row)) {\n            throw new ArgumentError('manifestPath', `row ${index + 1} must be an object`);\n        }\n        const id = String(row.id || '').trim().toLowerCase();\n        if (!GROK_CONVERSATION_ID_RE.test(id)) {\n            throw new ArgumentError('manifestPath', `row ${index + 1} is missing a valid Grok conversation id`);\n        }\n        return {\n            id,\n            title: row.title == null || row.title === '' ? '' : String(row.title),\n            date: row.date == null || row.date === '' ? '' : String(row.date),\n            url: normalizeGrokUrl(row.url, id, (reason) => new ArgumentError('manifestPath', `row ${index + 1}: ${reason}`)),\n        };\n    });\n}\n","sourceCodeStart":63,"sourceCodeEnd":95,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/grok/export-utils.js#L63-L95","documentation":"normalizeManifestRows validates each element of the manifest array is a plain object. This ArgumentError is thrown when row N is null, undefined, a primitive, or an array. The manifest must contain only object rows so id/title/date/url can be read.","triggerScenarios":"A --manifestPath file whose array contains a null element (common with JSON.stringify of sparse arrays or a manually edited file), a string/number element, or a nested array; detail: `row ${index + 1} must be an object`.","commonSituations":"Manifest was generated with `[...].filter()` producing holes rendered as null; a template or script interpolated wrong values; someone concatenated two export files and an array got nested inside an array; hand-merging manifests introduced a stray entry.","solutions":["Open the manifest JSON, locate element N-1 (index is 1-based in the message), and remove/fix the non-object entry.","Regenerate the manifest via grok/export instead of editing it manually.","Pre-clean before normalizing: rows.filter((r) => r && typeof r === 'object' && !Array.isArray(r)).","If merging manifests, merge with [].concat(...arrays) and re-validate rather than pasting arrays inside arrays."],"exampleFix":"// before\nconst rows = JSON.parse(raw); // [null, { id: '...' }]\nnormalizeManifestRows(rows);\n\n// after\nconst rows = JSON.parse(raw).filter((r) => r && typeof r === 'object' && !Array.isArray(r));\nnormalizeManifestRows(rows);","handlingStrategy":"validation","validationCode":"const parsed = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));\nconst badIdx = parsed.findIndex((r) => !r || typeof r !== 'object' || Array.isArray(r));\nif (badIdx !== -1) throw new Error(`manifest row ${badIdx + 1} is not an object`);","typeGuard":"function isPlainObjectRow(row) {\n  return typeof row === 'object' && row !== null && !Array.isArray(row);\n}","tryCatchPattern":"try {\n  const rows = normalizeManifestRows(parsed);\n} catch (err) {\n  if (err instanceof ArgumentError && /must be an object/.test(err.message)) {\n    console.error(`Bad manifest entry — ${err.message}; clean the manifest and retry.`);\n  } else throw err;\n}","preventionTips":["Sanitize arrays (strip nulls/primitives) before writing or consuming manifests.","Avoid sparse-array construction when generating manifests.","Diff manifests against a fresh grok/export after merging files."],"tags":["validation","json-schema","manifest","grok-export"],"backgroundTag":"schema-validation-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}