benbjohnson/litestream · error
invalid sync_interval: %w
Error message
invalid sync_interval: %w
What it means
VFSConfig.Set validates URI/config parameters. The sync_interval value must parse as a Go time.ParseDuration string (e.g. "10s", "1m"). This error wraps the underlying parse failure when the value is not a valid duration.
Source
Thrown at vfs_config.go:69
}
func DeleteVFSConfig(dbName string) {
vfsConfigsMu.Lock()
defer vfsConfigsMu.Unlock()
delete(vfsConfigs, dbName)
}
func (cfg *VFSConfig) Set(key, value string) error {
switch key {
case "replica_url":
cfg.ReplicaURL = value
case "write_enabled":
b := strings.ToLower(value) == "true" || value == "1"
cfg.WriteEnabled = &b
case "sync_interval":
d, err := time.ParseDuration(value)
if err != nil {
return fmt.Errorf("invalid sync_interval: %w", err)
}
cfg.SyncInterval = &d
case "buffer_path":
cfg.BufferPath = value
case "hydration_enabled":
b := strings.ToLower(value) == "true" || value == "1"
cfg.HydrationEnabled = &b
case "hydration_path":
cfg.HydrationPath = value
case "poll_interval":
d, err := time.ParseDuration(value)
if err != nil {
return fmt.Errorf("invalid poll_interval: %w", err)
}
cfg.PollInterval = &d
case "cache_size":
n, err := strconv.Atoi(value)
if err != nil {View on GitHub (pinned to 4ed7a308f6)
Solutions
- Use a valid Go duration string with a unit suffix, e.g. sync_interval=10s
- Fix the URI/config value: examples 1s, 500ms, 1m30s
- If building values programmatically, use time.Duration.String() to render the value
Example fix
// before litestream://file:///db?sync_interval=10 // after litestream://file:///db?sync_interval=10s
Defensive patterns
Strategy: validation
Validate before calling
d, err := time.ParseDuration(v)
if err != nil { return fmt.Errorf("sync_interval must be a Go duration like 10s: %w", err) }
_ = d Try / catch
if err := cfg.Set("sync_interval", v); err != nil {
if strings.Contains(err.Error(), "invalid sync_interval") {
// surface the wrapped time.ParseDuration message to the operator
}
} Prevention
- Always include a unit suffix in duration config values (s, m, h)
- Test URI config parsing in CI before deploying
- Generate duration strings via time.Duration.String()
When it happens
Trigger: Calling Set("sync_interval", <value>) — directly or via ParseVFSURIConfig from a VFS URI like litestream://...?sync_interval=xyz — where the value fails time.ParseDuration (e.g. "10", "abc", "10sec").
Common situations: Writing sync_interval=10 without a unit in the VFS URI or config file; using unit spellings Go does not accept (sec, mins); copy/paste from non-Go documentation.
Understand the failure class
Background: "invalid duration" / "failed to parse duration": why your timeout, interval, or TTL string is rejected and which formats each library accepts — this error's family across 32 libraries.
Related errors
- invalid poll_interval: %w
- heartbeat interval must be at least 1 minute
- invalid cache_size: %w
- unknown config key: %s
- snapshot interval must be greater than 0
AI-assisted analysis of benbjohnson/litestream@4ed7a308f6 (2026-09-06).
Data as JSON: /api/errors/de33ed0f731b3d90.
Report an issue: GitHub.