{"record":{"id":"1373330e7f35b1f6","repo":"paperclipai/paperclip","slug":"invalid-retention-days-string-candidate-use","errorCode":null,"errorMessage":"Invalid retention days '${String(candidate)}'. Use a positive integer.","messagePattern":"Invalid retention days '(.+?)'\\. Use a positive integer\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/db-backup.ts","lineNumber":40,"sourceCode":"  const envUrl = process.env.DATABASE_URL?.trim();\n  if (envUrl) return { value: envUrl, source: \"DATABASE_URL\" };\n\n  const config = readConfig(configPath);\n  if (config?.database.mode === \"postgres\" && config.database.connectionString?.trim()) {\n    return { value: config.database.connectionString.trim(), source: \"config.database.connectionString\" };\n  }\n\n  const port = config?.database.embeddedPostgresPort ?? 54329;\n  return {\n    value: `postgres://paperclip:paperclip@127.0.0.1:${port}/paperclip`,\n    source: `embedded-postgres@${port}`,\n  };\n}\n\nfunction normalizeRetentionDays(value: number | undefined, fallback: number): number {\n  const candidate = value ?? fallback;\n  if (!Number.isInteger(candidate) || candidate < 1) {\n    throw new Error(`Invalid retention days '${String(candidate)}'. Use a positive integer.`);\n  }\n  return candidate;\n}\n\nfunction resolveBackupDir(raw: string): string {\n  return path.resolve(expandHomePrefix(raw.trim()));\n}\n\nexport async function dbBackupCommand(opts: DbBackupOptions): Promise<void> {\n  printPaperclipCliBanner();\n  p.intro(pc.bgCyan(pc.black(\" paperclip db:backup \")));\n\n  const configPath = resolveConfigPath(opts.config);\n  const config = readConfig(opts.config);\n  const connection = resolveConnectionString(opts.config);\n  const defaultDir = resolveDefaultBackupDir(resolvePaperclipInstanceId());\n  const configuredDir = opts.dir?.trim() || config?.database.backup.dir || defaultDir;\n  const backupDir = resolveBackupDir(configuredDir);","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/cli/src/commands/db-backup.ts#L22-L58","documentation":"normalizeRetentionDays rejects a backup retention-days value that is not a positive integer; a numeric-config guard for db-backup.","triggerScenarios":"Thrown at cli/src/commands/db-backup.ts:40 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a positive integer for retention days."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"120ae5428fa29bee300bcf806491cd4d965fbb7c","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}