paperclipai/paperclip · error · Error

Invalid worktree seed-pending marker at ${filePath}: ${error

Error message

Invalid worktree seed-pending marker at ${filePath}: ${error instanceof Error ? error.message : String(error)}

What it means

Thrown by readWorktreeSeedPendingMarker when the pending marker file cannot be JSON.parse'd or read. This indicates the marker file is corrupt, truncated, or not valid JSON. The raw parse error message is appended for diagnosis.

Source

Thrown at cli/src/commands/worktree.ts:1439

  seedMode?: WorktreeSeedMode;
  now?: Date;
}): void {
  const markers = resolveWorktreeSeedMarkerPaths(input.configPath);
  writeWorktreeSeedMarker(markers.complete, {
    version: 1,
    state: "complete",
    seedMode: input.seedMode ?? "minimal",
    completedAt: (input.now ?? new Date()).toISOString(),
  });
  rmSync(markers.pending, { force: true });
}

function readWorktreeSeedPendingMarker(filePath: string): WorktreeSeedPendingMarker {
  let parsed: unknown;
  try {
    parsed = JSON.parse(readFileSync(filePath, "utf8"));
  } catch (error) {
    throw new Error(
      `Invalid worktree seed-pending marker at ${filePath}: ${error instanceof Error ? error.message : String(error)}`,
    );
  }

  if (
    !parsed
    || typeof parsed !== "object"
    || (parsed as { version?: unknown }).version !== 1
    || (parsed as { state?: unknown }).state !== "pending"
    || typeof (parsed as { sourceConfigPath?: unknown }).sourceConfigPath !== "string"
    || !(parsed as { sourceConfigPath: string }).sourceConfigPath.trim()
  ) {
    throw new Error(`Invalid worktree seed-pending marker at ${filePath}.`);
  }

  return parsed as WorktreeSeedPendingMarker;
}

View on GitHub (pinned to 67001ec6eb)

Solutions

  1. Inspect the marker file content to confirm it is invalid JSON.
  2. If no seed is running, delete the corrupt pending marker and re-trigger the seed (it will be regenerated).
  3. Ensure only one seed process writes the marker at a time (the seed lock guards this).
  4. Restore from backup if the marker contained needed sourceConfigPath info before deleting.

Example fix

# before: corrupt marker
# after
rm .paperclip/seed-pending.json && paperclipai worktree reseed ...
Defensive patterns

Strategy: validation

Validate before calling

function markerParses(filePath: string): boolean {
  try { JSON.parse(fs.readFileSync(filePath, 'utf8')); return true; } catch { return false; }
}

Try / catch

try {
  readWorktreeSeedPendingMarker(markers.pending);
} catch (e) {
  if (/Invalid worktree seed-pending marker/.test((e as Error).message)) {
    if (noSeedRunning) fs.rmSync(markers.pending, { force: true });
  }
}

Prevention

When it happens

Trigger: The pending marker file was written partially (crash during writeWorktreeSeedMarker); another process wrote a non-JSON file at the marker path; disk corruption or manual editing broke the JSON; the file is empty.

Common situations: Previous seed process killed mid-write; concurrent writers racing on the marker path; filesystem full at write time truncating the file; user manually editing the marker.

Related errors


AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12). Data as JSON: /api/errors/c3706310070b00a4. Report an issue: GitHub.