diegosouzapw/OmniRoute · error · Error

Backup metadata not found

Error message

Backup metadata not found: ${backupId}

What it means

Thrown by restoreBackup() when the `.meta.json` sidecar for the given backupId cannot be read or parsed — the backup id does not correspond to an existing, well-formed backup record. The id may be stale (backup deleted) or malformed.

Solutions

  1. List available backups for the tool first and use a valid backupId
  2. Re-create the backup if its metadata file was lost or corrupted
  3. Verify the backupId has no path characters (safePath would have thrown traversal instead)
  4. Return 404 to the API caller for unknown backup ids
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/shared/services/backupService.ts:162 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/135fa6a49bd9215a. Report an issue: GitHub.

Appendix: source

Thrown at src/shared/services/backupService.ts:162

  return backups;
}

/**
 * Restore a backup by its id (filename).
 */
export async function restoreBackup(toolId: string, backupId: string) {
  const dir = getToolBackupDir(toolId);
  // Anchor backupId within the tool dir — prevent path traversal via backupId
  const backupPath = safePath(toolId, backupId);
  const metaPath = backupPath + ".meta.json";

  // Read metadata to find original path
  let meta;
  try {
    const raw = await fs.readFile(metaPath, "utf-8");
    meta = JSON.parse(raw);
  } catch {
    throw new Error(`Backup metadata not found: ${backupId}`);
  }

  // Verify actual backup file exists
  try {
    await fs.access(backupPath);
  } catch {
    throw new Error(`Backup file not found: ${backupId}`);
  }

  // Before restoring, back up the current file (so restore is reversible)
  await createBackup(toolId, meta.originalPath);

  // Copy backup over the original
  const targetDir = path.dirname(meta.originalPath);
  await fs.mkdir(targetDir, { recursive: true });
  await fs.copyFile(backupPath, meta.originalPath);

  return {

View on GitHub (pinned to a179ffed5b)