{"record":{"id":"5256bf64a00f0809","repo":"benbjohnson/litestream","slug":"w-s","errorCode":null,"errorMessage":"%w: %s","messagePattern":"%w: %s","errorType":"validation","errorClass":"ErrConfigFileNotFound","httpStatus":null,"severity":"error","filePath":"cmd/litestream/main.go","lineNumber":608,"sourceCode":"\t\t\treturn dbConfig\n\t\t}\n\t}\n\treturn nil\n}\n\n// OpenConfigFile opens a configuration file and returns a reader.\n// Expands the filename path if needed.\nfunc OpenConfigFile(filename string) (io.ReadCloser, error) {\n\t// Expand filename, if necessary.\n\tfilename, err := expand(filename)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Open configuration file.\n\tf, err := os.Open(filename)\n\tif os.IsNotExist(err) {\n\t\treturn nil, fmt.Errorf(\"%w: %s\", ErrConfigFileNotFound, filename)\n\t} else if err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn f, nil\n}\n\n// ReadConfigFile unmarshals config from filename. Expands path if needed.\n// If expandEnv is true then environment variables are expanded in the config.\nfunc ReadConfigFile(filename string, expandEnv bool) (Config, error) {\n\tf, err := OpenConfigFile(filename)\n\tif err != nil {\n\t\treturn DefaultConfig(), err\n\t}\n\tdefer f.Close()\n\n\treturn ParseConfig(f, expandEnv)\n}","sourceCodeStart":590,"sourceCodeEnd":626,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/main.go#L590-L626","documentation":"OpenConfigFile wraps the failure to open the config file: when os.Open fails because the file does not exist, it returns fmt.Errorf(\"%w: %s\", ErrConfigFileNotFound, filename), so callers can match errors.Is(err, litestream.ErrConfigFileNotFound) (as in main.go where it prints 'open <file>: no such file or directory'-style guidance). This indicates the -config path passed on the command line cannot be found.","triggerScenarios":"Running `litestream -config /path/to.yml` where /path/to.yml does not exist; OpenConfigFile is called from ReadConfigFile during startup.","commonSituations":"Typo in the config path; running from the wrong working directory with a relative path; config file deleted or never created; systemd unit pointing at a stale path.","solutions":["Check the path passed to -config with `ls <path>` and fix typos.","Use an absolute path (or run from the directory containing the config).","Create the config file if it does not exist yet (`litestream.yml`)."],"exampleFix":"// before\nlitestream -config ./litestream-prod.yml\n// after\nlitestream -config /etc/litestream/litestream.yml","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(configPath); os.IsNotExist(err) {\n    return fmt.Errorf(\"config file %q does not exist\", configPath)\n}","typeGuard":null,"tryCatchPattern":"if err := run(); err != nil {\n    if errors.Is(err, litestream.ErrConfigFileNotFound) {\n        log.Fatalf(\"config file missing: use -config <path>\")\n    }\n}","preventionTips":["Always pass absolute config paths","Check file existence in service units before start","Keep config files under version control"],"tags":["config","file","startup"],"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-14T00:17:10.932Z"}