{"record":{"id":"135fa6a49bd9215a","repo":"diegosouzapw/OmniRoute","slug":"backup-metadata-not-found-backupid","errorCode":null,"errorMessage":"Backup metadata not found: ${backupId}","messagePattern":"Backup metadata not found: (.+?)","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/shared/services/backupService.ts","lineNumber":162,"sourceCode":"  return backups;\n}\n\n/**\n * Restore a backup by its id (filename).\n */\nexport async function restoreBackup(toolId: string, backupId: string) {\n  const dir = getToolBackupDir(toolId);\n  // Anchor backupId within the tool dir — prevent path traversal via backupId\n  const backupPath = safePath(toolId, backupId);\n  const metaPath = backupPath + \".meta.json\";\n\n  // Read metadata to find original path\n  let meta;\n  try {\n    const raw = await fs.readFile(metaPath, \"utf-8\");\n    meta = JSON.parse(raw);\n  } catch {\n    throw new Error(`Backup metadata not found: ${backupId}`);\n  }\n\n  // Verify actual backup file exists\n  try {\n    await fs.access(backupPath);\n  } catch {\n    throw new Error(`Backup file not found: ${backupId}`);\n  }\n\n  // Before restoring, back up the current file (so restore is reversible)\n  await createBackup(toolId, meta.originalPath);\n\n  // Copy backup over the original\n  const targetDir = path.dirname(meta.originalPath);\n  await fs.mkdir(targetDir, { recursive: true });\n  await fs.copyFile(backupPath, meta.originalPath);\n\n  return {","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/shared/services/backupService.ts#L144-L180","documentation":"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.","triggerScenarios":"Thrown at src/shared/services/backupService.ts:162 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["List available backups for the tool first and use a valid backupId","Re-create the backup if its metadata file was lost or corrupted","Verify the backupId has no path characters (safePath would have thrown traversal instead)","Return 404 to the API caller for unknown backup ids"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}