{"record":{"id":"3f9e6477639f738d","repo":"benbjohnson/litestream","slug":"config-file-not-found","errorCode":null,"errorMessage":"config file not found","messagePattern":"config file not found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/main.go","lineNumber":63,"sourceCode":"\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}\n\nfunc (e *ConfigValidationError) Unwrap() error {\n\treturn e.Err","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/main.go#L45-L81","documentation":"ErrConfigFileNotFound is returned by OpenConfigFile when the config file passed via -config (or the default path) does not exist on disk. The filename is wrapped into the message with fmt.Errorf %w so errors.Is still matches.","triggerScenarios":"Calling OpenConfigFile(filename) where os.Open returns os.IsNotExist — i.e. the -config path is wrong, the file was deleted, or the default config path is absent while no explicit path was given.","commonSituations":"Running litestream with -config /etc/litestream.yml on a fresh install where the file was never created, typo in the filename, or running from a different working directory with a relative path.","solutions":["Check the path exists: ls the exact filename passed to -config","Create the config file at DefaultConfigPath() if you intended default behavior","Use an absolute path instead of a relative one","Handle errors.Is(err, ErrConfigFileNotFound) in code that tolerates missing configs"],"exampleFix":"// before\nlitestream -config litestream.yml  // run from wrong cwd\n// after\nlitestream -config /etc/litestream/litestream.yml","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(cfgPath); os.IsNotExist(err) {\n    return fmt.Errorf(\"config file %s does not exist\", cfgPath)\n}","typeGuard":null,"tryCatchPattern":"if err := litestreamRun(ctx); err != nil {\n    if errors.Is(err, main.ErrConfigFileNotFound) {\n        slog.Error(\"config missing; generate one with 'litestream config'\", \"err\", err)\n        os.Exit(1)\n    }\n    return err\n}","preventionTips":["Use absolute paths for -config in systemd/containers","Generate the default config before first run","Check the working directory when using relative paths"],"tags":["config","file","cli"],"backgroundTag":"config-file-not-found","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"}