{"record":{"id":"42b746ff7f9e1fe8","repo":"diegosouzapw/OmniRoute","slug":"backup-not-found-backupid","errorCode":null,"errorMessage":"Backup not found: ${backupId}","messagePattern":"Backup not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/lib/db/backup.ts","lineNumber":388,"sourceCode":"    !backupId.startsWith(\"db_\") ||\n    !backupId.endsWith(\".sqlite\") ||\n    backupId.includes(path.sep) ||\n    backupId.includes(\"/\")\n  ) {\n    throw new Error(\"Invalid backup ID\");\n  }\n\n  const backupPath = path.resolve(backupDir, backupId);\n  // Prevent path traversal: resolved path must stay within backupDir\n  if (\n    !backupPath.startsWith(path.resolve(backupDir) + path.sep) &&\n    backupPath !== path.resolve(backupDir)\n  ) {\n    throw new Error(\"Invalid backup ID: path traversal detected\");\n  }\n\n  if (!fs.existsSync(backupPath)) {\n    throw new Error(`Backup not found: ${backupId}`);\n  }\n\n  // Validate backup integrity\n  try {\n    const { tryOpenSync } = await import(\"@/lib/db/adapters/driverFactory\");\n    const testDb = tryOpenSync(backupPath, { readonly: true });\n    if (!testDb) {\n      throw new Error(\"Backup file is corrupt: could not open\");\n    }\n    let result: Array<{ integrity_check?: string }>;\n    try {\n      result = testDb.pragma(\"integrity_check\") as Array<{ integrity_check?: string }>;\n    } finally {\n      testDb.close();\n    }\n    if (result[0]?.integrity_check !== \"ok\") {\n      throw new Error(\"Backup integrity check failed\");\n    }","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/db/backup.ts#L370-L406","documentation":"Error \"Backup not found: ${backupId}\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/db/backup.ts:388 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}