paperclipai/paperclip · error

No previous managed payload is available for rollback.

Error message

No previous managed payload is available for rollback.

What it means

Thrown by rollbackManagedInstall when a manifest exists but its `previous` array is empty (manifest.previous[0] is undefined). Rollback swaps the current payload with the most recent prior entry; with no prior payload recorded there is nothing to roll back to. This happens when the current install is the first managed install or all previous entries were pruned.

Source

Thrown at cli/src/commands/update.ts:132

  return 0;
}

export function resolveUpdateRequest(manifest: InstallManifest | null, options: Pick<UpdateOptions, "canary" | "latest" | "version">): { spec: string; channel: InstallChannel; explicit: boolean } {
  const selected = Number(Boolean(options.canary)) + Number(Boolean(options.latest)) + Number(Boolean(options.version));
  if (selected > 1) throw new Error("Choose only one of --latest, --canary, or --version.");
  if (options.version) return { spec: options.version.trim(), channel: "pinned", explicit: true };
  if (options.canary) return { spec: "canary", channel: "canary", explicit: true };
  if (options.latest) return { spec: "latest", channel: "latest", explicit: true };
  if (manifest?.channel === "pinned") return { spec: manifest.version, channel: "pinned", explicit: false };
  const channel = manifest?.channel === "canary" ? "canary" : "latest";
  return { spec: channel, channel, explicit: false };
}

export function rollbackManagedInstall(paths = resolveInstallStorePaths()): InstallManifest {
  const manifest = readInstallManifest(paths);
  if (!manifest) throw new Error("No managed install was found to roll back.");
  const target = manifest.previous[0];
  if (!target) throw new Error("No previous managed payload is available for rollback.");
  if (!fs.existsSync(target.payloadPath)) throw new Error(`Previous payload is missing: ${target.payloadPath}`);
  const current: InstallRecord = { source: manifest.source, version: manifest.version, channel: manifest.channel, payloadPath: manifest.payloadPath, repo: manifest.repo, ref: manifest.ref, sha: manifest.sha, installedAt: manifest.installedAt };
  const next: InstallManifest = { schemaVersion: manifest.schemaVersion, ...target, previous: [current, ...manifest.previous.slice(1)].slice(0, 2) };
  const oldTarget = fs.readlinkSync(paths.currentPath);
  flipCurrentAtomic(target.payloadPath, paths);
  try { writeInstallManifestAtomic(next, paths); } catch (error) { flipCurrentAtomic(path.resolve(paths.cliRoot, oldTarget), paths); throw error; }
  return next;
}

async function defaultConfirm(message: string): Promise<boolean> {
  if (!process.stdin.isTTY || !process.stdout.isTTY) return false;
  const answer = await p.confirm({ message, initialValue: false });
  return !p.isCancel(answer) && answer === true;
}
function emit(options: UpdateOptions, value: Record<string, unknown>, message: string): void { if (options.json) console.log(JSON.stringify(value, null, 2)); else console.log(message); }

async function rollbackAfterServiceValidationFailure(
  paths: InstallStorePaths,

View on GitHub (pinned to 67001ec6eb)

Solutions

  1. There is no prior payload to restore — reinstall the desired version directly: `paperclipai install --version <semver>` or `paperclipai update --version <semver>`.
  2. Restore a known-good payload directory and prepend it to the manifest's previous[] array, then retry rollback.
  3. Keep at least one update between rollbacks so the previous[] history is populated.
Defensive patterns

Strategy: validation

Validate before calling

import { readInstallStorePaths, readInstallManifest } from '../install-store.js';
function hasPreviousPayload(): boolean {
  const manifest = readInstallManifest(resolveInstallStorePaths());
  return Boolean(manifest && manifest.previous.length > 0);
}
// if (!hasPreviousPayload()) { /* install desired version directly, no rollback */ }

Try / catch

try {
  rollbackManagedInstall(paths);
} catch (error) {
  if (error instanceof Error && error.message === 'No previous managed payload is available for rollback.') {
    // no history — install the target version explicitly instead
    await updateCommand({ version: desiredVersion, yes: true });
  } else throw error;
}

Prevention

When it happens

Trigger: Running `paperclipai update --rollback` on a freshly installed managed CLI that has only ever had one payload (no prior version). Also if pruneInstallPayloads or manual manifest editing emptied the previous[] array.

Common situations: First update attempt immediately after initial install. Manifest hand-edited to clear history. Older payload directories deleted from disk and manifest cleaned up to match.

Related errors


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