{"record":{"id":"fd58550963b27f34","repo":"benbjohnson/litestream","slug":"shutdown-sync-timeout-must-be-0","errorCode":null,"errorMessage":"shutdown-sync-timeout must be >= 0","messagePattern":"shutdown-sync-timeout must be >= 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/main.go","lineNumber":59,"sourceCode":"var 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 {\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)","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/main.go#L41-L77","documentation":"Sentinel error ErrInvalidShutdownSyncTimeout is returned by Config.Validate when shutdown-sync-timeout is configured with a negative value. This timeout bounds how long litestream waits for a final sync during shutdown; zero is allowed (no wait), but negative values are rejected. Wrapped in ConfigValidationError with Field \"shutdown-sync-timeout\".","triggerScenarios":"Setting shutdown-sync-timeout to a negative duration in the top-level config and running Validate.","commonSituations":"Sign typo in the duration string; computed values going negative; misunderstanding that 0 (not a negative) disables the shutdown wait.","solutions":["Set shutdown-sync-timeout to a non-negative duration (e.g. \"30s\"); use 0 to skip the shutdown sync wait.","Check for sign or arithmetic errors in the value source.","Remove the key entirely to use the default timeout."],"exampleFix":"# before\nshutdown-sync-timeout: -1m\n# after\nshutdown-sync-timeout: 30s","handlingStrategy":"validation","validationCode":"if cfg.ShutdownSyncTimeout != nil && *cfg.ShutdownSyncTimeout < 0 {\n    return errors.New(\"shutdown-sync-timeout 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.ErrInvalidShutdownSyncTimeout) {\n        return fmt.Errorf(\"shutdown timeout %v is negative\", ve.Value)\n    }\n    return err\n}","preventionTips":["Use 0 to skip the shutdown sync wait; negative values are never valid.","Watch for sign errors when deriving timeouts from other durations.","Validate the config in CI and at startup."],"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"}