google-gemini/gemini-cli · error
Invalid retention period: ${period}. Value must be greater t
Error message
Invalid retention period: ${period}. Value must be greater than 0 What it means
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.
Source
Thrown at packages/cli/src/utils/sessionCleanup.ts:402
/**
* Parses retention period strings like "30d", "7d", "24h" into milliseconds
* @throws {Error} If the format is invalid
*/
function parseRetentionPeriod(period: string): number {
const match = period.match(/^(\d+)([dhwm])$/);
if (!match) {
throw new Error(
`Invalid retention period format: ${period}. Expected format: <number><unit> where unit is h, d, w, or m`,
);
}
const value = parseInt(match[1], 10);
const unit = match[2];
// Reject zero values as they're semantically invalid
if (value === 0) {
throw new Error(
`Invalid retention period: ${period}. Value must be greater than 0`,
);
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
return value * MULTIPLIERS[unit as keyof typeof MULTIPLIERS];
}
/**
* Validates retention configuration
*/
function validateRetentionConfig(
config: Config,
retentionConfig: SessionRetentionSettings,
): string | null {
if (!retentionConfig.enabled) {
return 'Retention not enabled';
}View on GitHub (pinned to 5024443c72)
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.
Example fix
// before // retention: '0d' // after // retention: '7d'
Defensive patterns
Strategy: validation
Validate before calling
function parseRetentionSafe(period) {
const m = period.match(/^(\d+)([dhwm])$/);
if (!m) throw new Error('Invalid format');
if (parseInt(m[1], 10) === 0) throw new Error('Value must be > 0');
return parseInt(m[1], 10) * MULTIPLIERS[m[2]];
} Prevention
- Reject zero values in the UI before saving.
- Use a dedicated 'disabled' flag instead of '0d' to turn cleanup off.
When it happens
Trigger: period matches the regex but parseInt(match[1]) === 0. Input like '0d', '0w', '0m', '0h'.
Common situations: 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.
Related errors
- Invalid retention period format: ${period}. Expected format:
- Invalid approval mode: ${rawApprovalMode}. Valid values are:
- Invalid telemetry configuration: ${err.message}.
- Invalid regex pattern in allowedExtensions setting: "${patte
- Invalid environment variable name: "${key}". Must contain on
AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12).
Data as JSON: /api/errors/ecb468dc9ceb17fb.
Report an issue: GitHub.