{"record":{"id":"6def2dda94e8ce05","repo":"benbjohnson/litestream","slug":"compaction-interval-must-be-greater-than-0","errorCode":null,"errorMessage":"compaction interval must be greater than 0","messagePattern":"compaction interval must be greater than 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/main.go","lineNumber":55,"sourceCode":")\n\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 {","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/main.go#L37-L73","documentation":"Sentinel error ErrInvalidCompactionInterval is returned by Config.Validate when any compaction levels[<i>].interval entry is <= 0. Compaction levels define how L0 LTX files are compacted at higher levels, and each level requires a positive interval. Wrapped in ConfigValidationError with Field \"levels[<i>].interval\".","triggerScenarios":"A levels[] array in the config (or per-db levels) containing an entry with interval: 0 or a negative value; loading such a config and running Validate — also asserted in main_test.go via errors.Is(err, ErrInvalidCompactionInterval).","commonSituations":"Adding a new compaction level and forgetting its interval; templated configs where a level's interval variable is empty/zero; hand-editing YAML/TOML and dropping the value.","solutions":["Give every levels[i] entry a positive interval (e.g. interval: \"1h\").","Remove the empty/zero interval level entry if it is not needed.","Fix whatever generator/template emitted a zero interval for that level."],"exampleFix":"# before\nlevels:\n  - level: 2\n    interval: 0\n# after\nlevels:\n  - level: 2\n    interval: 1h","handlingStrategy":"validation","validationCode":"for i, lvl := range cfg.Levels {\n    if lvl.Interval <= 0 {\n        return fmt.Errorf(\"levels[%d].interval must be > 0\", i)\n    }\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.ErrInvalidCompactionInterval) {\n        return fmt.Errorf(\"compaction level invalid: %s=%v\", ve.Field, ve.Value)\n    }\n    return err\n}","preventionTips":["When adding a levels[] entry, always specify both level and a positive interval.","Check every element of the levels array, not just the first, after template rendering.","Test generated configs with cfg.Validate() in unit tests."],"tags":["go","configuration","validation","compaction"],"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"}