{"record":{"id":"66d030cf4865975e","repo":"benbjohnson/litestream","slug":"shutdown-sync-interval-must-be-greater-than-0","errorCode":null,"errorMessage":"shutdown sync interval must be greater than 0","messagePattern":"shutdown sync interval must be greater than 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/main.go","lineNumber":60,"sourceCode":"\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}\n\treturn fmt.Sprintf(\"%s: %v\", e.Field, e.Err)\n}","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/main.go#L42-L78","documentation":"Sentinel error ErrInvalidShutdownSyncInterval is returned by Config.Validate when shutdown-sync-interval is configured but <= 0. This interval controls the polling frequency of the final sync loop during shutdown and must be positive. Wrapped in ConfigValidationError with Field \"shutdown-sync-interval\".","triggerScenarios":"Setting shutdown-sync-interval: 0 or negative in the top-level config; Validate rejects the config before litestream starts.","commonSituations":"Setting 0 intending the tightest possible polling (choose a small positive value like 1s instead); templated configs with unset variables; copy-paste edits dropping the unit so the value parses to zero.","solutions":["Set shutdown-sync-interval to a small positive duration (e.g. \"1s\"), or remove the key for the default.","If you want an immediate shutdown sync, lower the timeout/interval semantics via shutdown-sync-timeout rather than zeroing the interval.","Fix the generating template or variable expansion producing zero."],"exampleFix":"# before\nshutdown-sync-interval: 0\n# after\nshutdown-sync-interval: 1s","handlingStrategy":"validation","validationCode":"if cfg.ShutdownSyncInterval != nil && *cfg.ShutdownSyncInterval <= 0 {\n    return errors.New(\"shutdown-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.ErrInvalidShutdownSyncInterval) {\n        return fmt.Errorf(\"shutdown sync interval %v invalid\", ve.Value)\n    }\n    return err\n}","preventionTips":["Pick a small positive polling interval (1s) instead of 0.","Never omit duration units; a bare 0 parses as an invalid zero interval.","Validate all shutdown-related settings together with cfg.Validate()."],"tags":["go","configuration","validation","shutdown"],"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"}