{"record":{"id":"ecb468dc9ceb17fb","repo":"google-gemini/gemini-cli","slug":"invalid-retention-period-period-value-must-be","errorCode":null,"errorMessage":"Invalid retention period: ${period}. Value must be greater than 0","messagePattern":"Invalid retention period: (.+?)\\. Value must be greater than 0","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/utils/sessionCleanup.ts","lineNumber":402,"sourceCode":"\n/**\n * Parses retention period strings like \"30d\", \"7d\", \"24h\" into milliseconds\n * @throws {Error} If the format is invalid\n */\nfunction parseRetentionPeriod(period: string): number {\n  const match = period.match(/^(\\d+)([dhwm])$/);\n  if (!match) {\n    throw new Error(\n      `Invalid retention period format: ${period}. Expected format: <number><unit> where unit is h, d, w, or m`,\n    );\n  }\n\n  const value = parseInt(match[1], 10);\n  const unit = match[2];\n\n  // Reject zero values as they're semantically invalid\n  if (value === 0) {\n    throw new Error(\n      `Invalid retention period: ${period}. Value must be greater than 0`,\n    );\n  }\n\n  // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion\n  return value * MULTIPLIERS[unit as keyof typeof MULTIPLIERS];\n}\n\n/**\n * Validates retention configuration\n */\nfunction validateRetentionConfig(\n  config: Config,\n  retentionConfig: SessionRetentionSettings,\n): string | null {\n  if (!retentionConfig.enabled) {\n    return 'Retention not enabled';\n  }","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/cli/src/utils/sessionCleanup.ts#L384-L420","documentation":"Thrown by parseRetentionPeriod when the regex matched but the numeric value parsed to 0 (e.g. '0d', '0h'). A zero retention period is semantically meaningless (it would delete everything immediately or never gate correctly), so it is rejected even though it is syntactically valid.","triggerScenarios":"period matches the regex but parseInt(match[1]) === 0. Input like '0d', '0w', '0m', '0h'.","commonSituations":"User sets retention to 0 intending 'disable' but the feature requires a positive duration. Default value misconfigured to '0d'. Copy/paste placeholder value left in config.","solutions":["Set a positive retention period such as '7d' or '24h'.","If you want to disable cleanup entirely, use the dedicated disable flag/setting rather than a zero period (check the cleanup config schema).","Validate retention > 0 in any UI that collects this value."],"exampleFix":"// before\n// retention: '0d'\n\n// after\n// retention: '7d'","handlingStrategy":"validation","validationCode":"function parseRetentionSafe(period) {\n  const m = period.match(/^(\\d+)([dhwm])$/);\n  if (!m) throw new Error('Invalid format');\n  if (parseInt(m[1], 10) === 0) throw new Error('Value must be > 0');\n  return parseInt(m[1], 10) * MULTIPLIERS[m[2]];\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Reject zero values in the UI before saving.","Use a dedicated 'disabled' flag instead of '0d' to turn cleanup off."],"tags":["session-cleanup","config","validation","business-rule"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}