jackwener/OpenCLI · error · CommandExecutionError

Twitter bookmarks resume file ${filePath} is already marked

Error message

Twitter bookmarks resume file ${filePath} is already marked complete

What it means

A resume file whose `complete` flag is true records a fully finished sync. readResumeFile refuses to resume such a file and throws this CommandExecutionError so a completed archive is not re-scrolled or overwritten.

Source

Thrown at clis/twitter/bookmarks.js:134

    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 bookmarks 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 (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 bookmarks resume file ${filePath} is missing in-memory tweets`);
        if (!expected.outputFile && parsed.tweets.length !== count)
            throw new CommandExecutionError(`Twitter bookmarks resume file ${filePath} count does not match its in-memory tweets`);
        if (parsed.complete)
            throw new CommandExecutionError(`Twitter bookmarks resume file ${filePath} is already marked complete`);
    }
    return {
        cursor,
        count,
        tweets: Array.isArray(parsed.tweets) ? parsed.tweets : [],
        complete: Boolean(parsed.complete),
        source: parsed.source || null,
        outputFile,
        updatedAt: parsed.updatedAt || null,
    };
}

// Keep this in sync with twitter/likes; wording is command-specific, so the
// atomic tmp-write/rename cleanup sequence intentionally remains local.
function writeResumeFile(filePath, payload) {
    if (!filePath)
        return;
    ensureParentDir(filePath);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Nothing to resume — read the completed JSONL archive (--output-file) or the previous results instead.
  2. Delete the completed resume file (and optionally keep the JSONL) before starting a fresh full sync.
  3. Check `parsed.complete` in the file first to detect an already-finished run.

Example fix

// before:
cli twitter bookmarks --all --resume-file ./b.json  # file has complete: true
// after: archive done; for a fresh run:
rm ./b.json && cli twitter bookmarks --all --resume-file ./b.json
Defensive patterns

Strategy: validation

Validate before calling

const parsed = JSON.parse(fs.readFileSync(resumeFile, 'utf8'));
if (parsed.complete) {
  // already done: consume the JSONL archive instead of resuming
  console.log('sync already complete; read', parsed.outputFile);
}

Type guard

function isCompletedResume(v) {
  return typeof v === 'object' && v !== null && v.complete === true;
}

Try / catch

try {
  await run(args);
} catch (e) {
  if (String(e.message).includes('is already marked complete')) {
    // no-op: previous run finished; read the output-file instead
  } else throw e;
}

Prevention

When it happens

Trigger: Re-running `twitter bookmarks --all --resume-file <path>` after a previous run finished successfully and marked `complete: true` in the file.

Common situations: Running the same command twice to 'refresh' data; a cron/job retrying after completion; forgetting the previous run already finished.

Related errors


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