jackwener/OpenCLI · error · ArgumentError
manifestPath row ${index + 1} must be an object
Error message
manifestPath row ${index + 1} must be an object What it means
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.
Source
Thrown at clis/grok/export-utils.js:81
if (!GROK_CONVERSATION_ID_RE.test(id)) {
throw new CommandExecutionError(`${label} returned a malformed row`, `Row ${index + 1} is missing a valid Grok conversation id.`);
}
return {
id,
title: row.title == null || row.title === '' ? '' : String(row.title),
date: row.date == null || row.date === '' ? '' : String(row.date),
url: normalizeGrokUrl(row.url, id, (reason) => new CommandExecutionError(`${label} returned a malformed row`, reason)),
};
});
}
export function normalizeManifestRows(rows) {
if (!Array.isArray(rows)) {
throw new ArgumentError('manifestPath', 'must point to a JSON array exported by grok/export');
}
return rows.map((row, index) => {
if (!row || typeof row !== 'object' || Array.isArray(row)) {
throw new ArgumentError('manifestPath', `row ${index + 1} must be an object`);
}
const id = String(row.id || '').trim().toLowerCase();
if (!GROK_CONVERSATION_ID_RE.test(id)) {
throw new ArgumentError('manifestPath', `row ${index + 1} is missing a valid Grok conversation id`);
}
return {
id,
title: row.title == null || row.title === '' ? '' : String(row.title),
date: row.date == null || row.date === '' ? '' : String(row.date),
url: normalizeGrokUrl(row.url, id, (reason) => new ArgumentError('manifestPath', `row ${index + 1}: ${reason}`)),
};
});
}
View on GitHub (pinned to 49907e53dc)
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.
Example fix
// before
const rows = JSON.parse(raw); // [null, { id: '...' }]
normalizeManifestRows(rows);
// after
const rows = JSON.parse(raw).filter((r) => r && typeof r === 'object' && !Array.isArray(r));
normalizeManifestRows(rows); Defensive patterns
Strategy: validation
Validate before calling
const parsed = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
const badIdx = parsed.findIndex((r) => !r || typeof r !== 'object' || Array.isArray(r));
if (badIdx !== -1) throw new Error(`manifest row ${badIdx + 1} is not an object`); Type guard
function isPlainObjectRow(row) {
return typeof row === 'object' && row !== null && !Array.isArray(row);
} Try / catch
try {
const rows = normalizeManifestRows(parsed);
} catch (err) {
if (err instanceof ArgumentError && /must be an object/.test(err.message)) {
console.error(`Bad manifest entry — ${err.message}; clean the manifest and retry.`);
} else throw err;
} Prevention
- 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.
When it happens
Trigger: 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`.
Common situations: 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.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- manifestPath must point to a JSON array exported by grok/exp
- manifestPath row ${index + 1} is missing a valid Grok conver
- ${label} returned a malformed row
- INVALID_ARGUMENT
- INVALID_ARGUMENT
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/7125c67a7a974815.
Report an issue: GitHub.