{"record":{"id":"380630ca5ce740ba","repo":"benbjohnson/litestream","slug":"snapshot-interval-must-be-greater-than-0","errorCode":null,"errorMessage":"snapshot interval must be greater than 0","messagePattern":"snapshot interval must be greater than 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/main.go","lineNumber":53,"sourceCode":"\t\"github.com/benbjohnson/litestream/sftp\"\n\t\"github.com/benbjohnson/litestream/webdav\"\n)\n\n// Version is set via -ldflags \"-X main.Version=...\" on release and Makefile\n// 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}","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/main.go#L35-L71","documentation":"Sentinel error ErrInvalidSnapshotInterval is returned by Config.Validate when a configured snapshot interval is present but less than or equal to zero. Snapshot interval controls how often litestream takes full snapshots, so a non-positive value is meaningless and rejected at config validation time. The error is wrapped in a ConfigValidationError that names the offending field (snapshot.interval or dbs[<id>].snapshot.interval) and its value.","triggerScenarios":"Setting snapshot.interval <= 0 in the top-level config, or snapshot.interval <= 0 under a dbs[] entry; calling Validate on a Config loaded from a TOML/YAML file containing such a value.","commonSituations":"Typo like interval = 0 intending 'use default'; a templated config where a variable expanded to 0 or an empty value coerced to 0; programmatically generating config with an unset duration defaulting to zero.","solutions":["Set snapshot.interval to a positive duration (e.g. \"24h\") in the config file, or remove the key to use the default.","If the value comes from a template/variable, ensure it expands to a valid positive duration.","Run litestream with the corrected config and re-check with `litestream -config <file> ...` validation output for the reported field."],"exampleFix":"# before\nsnapshot:\n  interval: 0\n# after\nsnapshot:\n  interval: 24h","handlingStrategy":"validation","validationCode":"func validSnapshotInterval(d time.Duration) bool { return d > 0 }\n// call before writing/loading config:\nif !validSnapshotInterval(cfg.Snapshot.IntervalDur) { return errors.New(\"snapshot.interval must be > 0\") }","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.ErrInvalidSnapshotInterval) {\n        log.Fatalf(\"bad snapshot interval at %s = %v\", ve.Field, ve.Value)\n    }\n    return err\n}","preventionTips":["Always write durations with explicit units (\"24h\") in litestream config files.","Validate the config with cfg.Validate() at load time, before starting services.","In templated configs, assert variables are non-empty before rendering intervals."],"tags":["go","configuration","validation","snapshot"],"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"}