jackwener/OpenCLI · error · CommandExecutionError

LinkedIn people search returned malformed row at index ${ind

Error message

LinkedIn people search returned malformed row at index ${index}

What it means

CommandExecutionError thrown inside normalizePeopleRows' map when an individual row is null or not an object. The rows array itself was valid, but at least one element is unusable, so the whole normalization aborts with the offending index in the message.

Source

Thrown at clis/linkedin/people-search.js:55

        const parsed = new URL(raw);
        const host = parsed.hostname.toLowerCase();
        if (parsed.protocol !== 'https:' || parsed.username || parsed.password || parsed.port) return '';
        if (host !== 'linkedin.com' && host !== 'www.linkedin.com') return '';
        const match = parsed.pathname.match(/^\/in\/([^/?#]+)\/?$/);
        if (!match || !match[1]) return '';
        return `https://www.linkedin.com/in/${match[1]}/`;
    } catch {
        return '';
    }
}

function normalizePeopleRows(rows) {
    if (!Array.isArray(rows)) {
        throw new CommandExecutionError('LinkedIn people search returned malformed extraction payload: missing rows array');
    }
    return rows.map((row, index) => {
        if (!row || typeof row !== 'object') {
            throw new CommandExecutionError(`LinkedIn people search returned malformed row at index ${index}`);
        }
        const name = normalizeWhitespace(row.name);
        const profileUrl = normalizeProfileUrl(row.profile_url);
        if (!name || !profileUrl) {
            throw new CommandExecutionError(`LinkedIn people search returned row without stable profile identity at index ${index}`);
        }
        return {
            name,
            headline: normalizeWhitespace(row.headline),
            location: normalizeWhitespace(row.location),
            profile_url: profileUrl,
        };
    });
}

function parseNonNegativeCount(value, label) {
    const count = Number(value);
    if (!Number.isInteger(count) || count < 0) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Update the extraction script to skip non-object entries instead of pushing them
  2. Increase wait time so rows finish rendering before extraction
  3. Filter invalid rows before normalizing: rows.filter(r => r && typeof r === 'object')
  4. Reproduce with the failing index and inspect that row's DOM to fix the per-row selector

Example fix

// before
return rows.map((row, index) => {
  if (!row || typeof row !== 'object') {
    throw new CommandExecutionError(`LinkedIn people search returned malformed row at index ${index}`);
  }
  ...
});
// after
return rows.filter((row) => row && typeof row === 'object').map((row) => { ... });
Defensive patterns

Strategy: validation

Validate before calling

const cleaned = rawRows.filter((r) => r && typeof r === 'object' && !Array.isArray(r));
if (cleaned.length < rawRows.length) console.warn(`dropped ${rawRows.length - cleaned.length} malformed rows`);

Type guard

function isUsableRow(r) {
  return typeof r === 'object' && r !== null && !Array.isArray(r);
}

Try / catch

try {
  return normalizePeopleRows(rows);
} catch (err) {
  const m = String(err.message).match(/malformed row at index (\d+)/);
  if (m) {
    rows.splice(Number(m[1]), 1);
    return normalizePeopleRows(rows);
  }
  throw err;
}

Prevention

When it happens

Trigger: The extraction script pushing null/undefined/primitive entries into the rows array — e.g. querySelectorAll matched container nodes whose expected child selectors returned nothing, or ad/promoted cards yielding null records.

Common situations: LinkedIn inserting promoted/ad cards with different markup; partial rendering when wait was too short; extraction script's per-row selector changes producing null entries mid-list.

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


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/662078a0102cb135. Report an issue: GitHub.