{"record":{"id":"fcf5c5d57ca29db5","repo":"benbjohnson/litestream","slug":"sync-interval-must-be-greater-than-0","errorCode":null,"errorMessage":"sync interval must be greater than 0","messagePattern":"sync interval must be greater than 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/main.go","lineNumber":56,"sourceCode":"\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}\n\nfunc (e *ConfigValidationError) Error() string {\n\tif e.Value != nil {","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/main.go#L38-L74","documentation":"Sentinel error ErrInvalidSyncInterval is returned by Config.Validate when a replica sync-interval is configured but <= 0. Sync interval controls how often a replica polls the database WAL for new data, so a non-positive value is rejected. Wrapped in ConfigValidationError with fields like dbs[<id>].replica.sync-interval or dbs[<id>].replicas[<i>].sync-interval.","triggerScenarios":"Setting sync-interval: 0 (or negative) under dbs[].replica, or under any entry of dbs[].replicas[]; running Validate on a config loaded with such values.","commonSituations":"Trying to make replication 'as fast as possible' with 0; templated configs where the interval variable is unset; copy-pasting a per-db replica block into a replicas[] list without fixing values.","solutions":["Set sync-interval to a positive duration (e.g. \"1s\"), or remove the key to use the default.","Check both the singular replica block and each entry of the replicas[] list in the offending dbs entry.","Correct the source (template, env expansion) that produced the zero value."],"exampleFix":"# before\ndbs:\n  - path: /data/app.db\n    replica:\n      sync-interval: 0\n# after\ndbs:\n  - path: /data/app.db\n    replica:\n      sync-interval: 1s","handlingStrategy":"validation","validationCode":"func validSyncInterval(d time.Duration) bool { return d > 0 }\nif db.Replica != nil && db.Replica.SyncInterval != nil && *db.Replica.SyncInterval <= 0 {\n    return errors.New(\"replica.sync-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.ErrInvalidSyncInterval) {\n        return fmt.Errorf(\"sync interval invalid at %s = %v\", ve.Field, ve.Value)\n    }\n    return err\n}","preventionTips":["Use a small positive value like 1s for near-real-time replication instead of 0.","Validate both single-replica and replicas[] list entries.","Omit sync-interval entirely to accept the default."],"tags":["go","configuration","validation","replication"],"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-14T00:17:10.932Z"}