benbjohnson/litestream · error

invalid poll_interval: %w

Error message

invalid poll_interval: %w

What it means

Validation in the VFS URI config Set method: the poll_interval parameter is not a valid Go duration string. Fires when parsing a vfs:// URI whose poll_interval query value cannot be parsed by time.ParseDuration (e.g. 'poll_interval=fast').

Source

Thrown at vfs_config.go:82

		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 {
			return fmt.Errorf("invalid cache_size: %w", err)
		}
		cfg.CacheSize = &n
	default:
		return fmt.Errorf("unknown config key: %s", key)
	}
	return nil
}

func ParseVFSURIConfig(uriParameters map[string]string) (*VFSConfig, error) {
	if len(uriParameters) == 0 {
		return nil, nil
	}

View on GitHub (pinned to 4ed7a308f6)

Solutions

  1. Supply a valid duration with unit, e.g. poll_interval=5s
  2. Correct the unit spelling to Go's ns/us/µs/ms/s/m/h set
  3. Render values with time.Duration.String() when generating config programmatically

Example fix

// before
litestream://file:///db?poll_interval=5
// after
litestream://file:///db?poll_interval=5s
Defensive patterns

Strategy: validation

Validate before calling

d, err := time.ParseDuration(v)
if err != nil { return fmt.Errorf("poll_interval must be a Go duration like 5s: %w", err) }
_ = d

Try / catch

if err := cfg.Set("poll_interval", v); err != nil {
    if strings.Contains(err.Error(), "invalid poll_interval") {
        // log the wrapped parse error and correct the value
    }
}

Prevention

When it happens

Trigger: Calling Set("poll_interval", <value>) — directly or via ParseVFSURIConfig from URI query parameters — where the value fails time.ParseDuration (e.g. "5", "every minute", "1h30").

Common situations: poll_interval=5 missing the unit in the connection URI; invalid unit like "5secs"; environment-specific config templating producing empty or malformed values.

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


AI-assisted analysis of benbjohnson/litestream@4ed7a308f6 (2026-09-06). Data as JSON: /api/errors/20f8cb971e7b8603. Report an issue: GitHub.