{"record":{"id":"560166726291b01f","repo":"benbjohnson/litestream","slug":"l0-retention-check-interval-must-be-greater-than-0","errorCode":null,"errorMessage":"l0 retention check interval must be greater than 0","messagePattern":"l0 retention check interval must be greater than 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/main.go","lineNumber":58,"sourceCode":"// builds; otherwise it is resolved from embedded VCS build info at startup.\nvar Version = defaultVersion\n\nfunc init() {\n\tbi, _ := debug.ReadBuildInfo()\n\tVersion = resolveVersion(Version, bi)\n}\n\n// errStop is a terminal error for indicating program should quit.\nvar errStop = errors.New(\"stop\")\n\n// Sentinel errors for configuration validation\nvar (\n\tErrInvalidSnapshotInterval         = errors.New(\"snapshot interval must be greater than 0\")\n\tErrInvalidSnapshotRetention        = errors.New(\"snapshot retention must be greater than 0\")\n\tErrInvalidCompactionInterval       = errors.New(\"compaction interval must be greater than 0\")\n\tErrInvalidSyncInterval             = errors.New(\"sync interval must be greater than 0\")\n\tErrInvalidL0Retention              = errors.New(\"l0 retention must not be negative\")\n\tErrInvalidL0RetentionCheckInterval = errors.New(\"l0 retention check interval must be greater than 0\")\n\tErrInvalidShutdownSyncTimeout      = errors.New(\"shutdown-sync-timeout must be >= 0\")\n\tErrInvalidShutdownSyncInterval     = errors.New(\"shutdown sync interval must be greater than 0\")\n\tErrInvalidHeartbeatURL             = errors.New(\"heartbeat URL must be a valid HTTP or HTTPS URL\")\n\tErrInvalidHeartbeatInterval        = errors.New(\"heartbeat interval must be at least 1 minute\")\n\tErrConfigFileNotFound              = errors.New(\"config file not found\")\n)\n\n// ConfigValidationError wraps a validation error with additional context\ntype ConfigValidationError struct {\n\tErr   error\n\tField string\n\tValue interface{}\n}\n\nfunc (e *ConfigValidationError) Error() string {\n\tif e.Value != nil {\n\t\treturn fmt.Sprintf(\"%s: %v (got %v)\", e.Field, e.Err, e.Value)\n\t}","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/main.go#L40-L76","documentation":"Sentinel error ErrInvalidL0RetentionCheckInterval is returned by Config.Validate when l0-retention-check-interval is configured but <= 0. This interval controls how often litestream runs the L0 retention cleanup check, so it must be positive. Wrapped in ConfigValidationError with Field \"l0-retention-check-interval\".","triggerScenarios":"Setting l0-retention-check-interval: 0 or a negative duration in the top-level config; Validate fails before the process starts — covered by main_test.go expecting errors.Is(err, ErrInvalidL0RetentionCheckInterval).","commonSituations":"Setting 0 intending 'never check' (instead remove the key or use defaults); templated config where the variable is empty and coerces to zero; unit typo producing zero-length duration.","solutions":["Set l0-retention-check-interval to a positive duration (e.g. \"10m\"), or remove the key to use the default.","If you want fewer cleanup passes, raise the interval rather than zeroing it.","Fix the template/source emitting the zero value."],"exampleFix":"# before\nl0-retention-check-interval: 0\n# after\nl0-retention-check-interval: 10m","handlingStrategy":"validation","validationCode":"if cfg.L0RetentionCheckInterval != nil && *cfg.L0RetentionCheckInterval <= 0 {\n    return errors.New(\"l0-retention-check-interval must be > 0\")\n}","typeGuard":null,"tryCatchPattern":"if err := cfg.Validate(); err != nil {\n    var ve *main.ConfigValidationError\n    if errors.As(err, &ve) && errors.Is(ve.Err, main.ErrInvalidL0RetentionCheckInterval) {\n        return fmt.Errorf(\"check interval %v at %s invalid\", ve.Value, ve.Field)\n    }\n    return err\n}","preventionTips":["To check less often, increase the interval — never set it to 0.","Ensure templated variables for intervals always render valid positive durations.","Run cfg.Validate() as a startup preflight."],"tags":["go","configuration","validation","retention"],"backgroundTag":"invalid-config-value","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}