jackwener/OpenCLI · error · CommandExecutionError

Twitter likes resume file ${filePath} is missing in-memory t

Error message

Twitter likes resume file ${filePath} is missing in-memory tweets

What it means

In in-memory mode (expected.outputFile is null), the resume file must embed the collected tweets array so the run can continue where it left off. readResumeFile throws this CommandExecutionError when the file lacks a valid `tweets` array — without it there is nothing to resume into memory.

Source

Thrown at clis/twitter/likes.js:147

    }
    const count = parsed?.count;
    const cursor = parsed?.cursor == null ? null : String(parsed.cursor);
    const outputFile = parsed?.outputFile ? path.resolve(String(parsed.outputFile)) : null;
    if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)
        || !Number.isInteger(count) || count < 0
        || (parsed.cursor != null && typeof parsed.cursor !== 'string')
        || (cursor !== null && !cursor.trim())) {
        throw new CommandExecutionError(`Twitter likes resume file ${filePath} has an invalid shape`);
    }
    if (expected) {
        if (parsed.source !== expected.source)
            throw new ArgumentError(`Resume file source mismatch: expected ${expected.source}, found ${parsed.source || 'unknown'}`);
        if (String(parsed.username || '').toLowerCase() !== String(expected.username).toLowerCase())
            throw new ArgumentError(`Resume file username mismatch: expected @${expected.username}, found @${parsed.username || 'unknown'}`);
        if (outputFile !== expected.outputFile)
            throw new ArgumentError(`Resume file output mismatch: expected ${expected.outputFile || 'in-memory mode'}, found ${outputFile || 'in-memory mode'}`);
        if (!expected.outputFile && !Array.isArray(parsed.tweets))
            throw new CommandExecutionError(`Twitter likes resume file ${filePath} is missing in-memory tweets`);
        if (!expected.outputFile && parsed.tweets.length !== count)
            throw new CommandExecutionError(`Twitter likes resume file ${filePath} count does not match its in-memory tweets`);
        if (parsed.complete)
            throw new CommandExecutionError(`Twitter likes resume file ${filePath} is already marked complete`);
    }
    return {
        cursor,
        count,
        tweets: Array.isArray(parsed.tweets) ? parsed.tweets : [],
        username: parsed.username || null,
        complete: Boolean(parsed.complete),
        source: parsed.source || null,
        outputFile,
        updatedAt: parsed.updatedAt || null,
    };
}

// Keep this in sync with twitter/bookmarks; wording is command-specific, so the

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use an output file (--output) for the run so resume files don't need embedded tweets, or obtain the original in-memory resume file including its tweets array
  2. Start a fresh in-memory run — in-memory resume files must be complete; partial ones cannot be repaired
  3. Re-export/recreate the resume file with the same library version that wrote it
  4. Validate the file contains `tweets` as an array before resuming

Example fix

// before (missing tweets in in-memory resume)
{"count": 42, "cursor": "abc", "source": "likes", "username": "userA"}
// after
{"count": 42, "cursor": "abc", "source": "likes", "username": "userA", "tweets": [ /* 42 tweets */ ]}
// or: re-run with --output so tweets go to the output file instead
Defensive patterns

Strategy: validation

Validate before calling

const parsed = JSON.parse(fs.readFileSync(resumePath, 'utf8'));
if (!expectedOutputFile && !Array.isArray(parsed.tweets))
  throw new Error('in-memory resume requires an embedded tweets array — use a complete in-memory resume or switch to --output mode');

Type guard

function hasInMemoryTweets(v) {
  return typeof v === 'object' && v !== null && Array.isArray(v.tweets) && v.tweets.length === v.count;
}

Try / catch

try {
  await runLikes({ resume: resumePath });
} catch (e) {
  if (/missing in-memory tweets/.test(e.message)) {
    return runLikes({ output: 'likes.json' }); // switch to output-file mode and start fresh
  }
  throw e;
}

Prevention

When it happens

Trigger: Resuming a `twitter likes` run that originally ran in in-memory mode, where parsed.tweets is missing or not an array (e.g. a file produced by an output-file run, or a hand-built/edited file that dropped the tweets field).

Common situations: Mixing resume files between output-file mode and in-memory mode; a manually truncated file where the large tweets array was removed to save space; schema drift from a different library version that stored tweets differently.

Related errors


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